472,989 Members | 3,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,989 software developers and data experts.

queue for large objects, object references

Hi,

in a data acquisition program I have several threads,
one thread grabbing images and another doing some
processing.
I'd like to make my own image class containing the image
and additional information (a lot of data, some Megabytes).
Then I'd like to transfer this object to another thread.
I tried to transfer an image over a queue and it works!
(see code below)
Is the data transferred or only a reference?
How could I hold the data global and transfer only a reference
that no data has to be copied (speed, memory)?

Thanks for any answer,

Markus

**************************************
import Image
import Queue
import thread
import time

class Send:
def __init__(self, queue, filename):
self.queue = queue
self.image = Image.open(filename, 'r')

def send(self):
self.queue.put(self.image)

class Recv:
def __init__(self, queue):
self.queue = queue
thread.start_new_thread(self.MyThread, (10,))

def MyThread(self, start):
while 1:
while not self.queue.empty():
img = self.queue.get()
img.save("result.bmp")

time.sleep(0.3)
msgq = Queue.Queue(0)

sender = Send(msgq, "test.bmp")
receiver = Recv(msgq)

sender.send()
time.sleep(2)
Jul 18 '05 #1
1 1961
> Is the data transferred or only a reference?

Everything in Python can be thought of as passed by reference. This
will mean different things to different people, which is why you should
look at these examples.

def funct(i): .... i += 1
.... k = 8
funct(k)
k 8

The integer doesn't get updated, because integers are immutable.

def funct(l): .... l = []
.... k = [1,2,3]
funct(k)
k [1, 2, 3]

Pointing the name 'l' to a new list object, doesn't change the object
that 'k' points to.

def funct(l): .... l[:] = []
.... k = [4,5,6]
funct(k)
k

[]

The list only gets updated when you actually modify the list pointed to
by the list named 'l'.
There are literally hundreds more examples I could go through. I'll let
you try to figure a few of those out.

- Josiah
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: WinstonSmith | last post by:
Hello everyone, I got a problem about GC when creating large fields (some MB), set reference to null and call GC.Collect. Not all virtual mem is released. Situation improved in .net 1.1 but not...
4
by: Richard Townsend | last post by:
I've been experimenting putting a reference to a function into a Queue object and was wondering what actually gets put in the Queue - is it the function's code object? If I read from the Queue...
1
by: Ross Johnson | last post by:
Hi, I'm moving a database from 7.0.2 to 7.3.3. The db contains several thousand large objects that I need to export. To do this I've managed to modify the contrib/pg_dumplo utility from 7.3.3...
6
by: Mountain Bikn' Guy | last post by:
What is the C# equivalent to calling PostMessage() in Win32 in order for an object to queue a message to itself? Thanks Mountain
5
by: Tim Marsden | last post by:
HI, I am developing a application in vb.net. I split down my functionality into several separate DLL's. The solution is becoming very large, nearly 100 projects, each project a dll's. There is...
21
by: ajbecker | last post by:
I'm trying to debug a problem I'm having where my finalizer queue is getting filled up faster than the thread can execute them, (or at least I think that's what's going on.) Is there a way that I...
7
by: copx | last post by:
How do you implement an event queue in C? The problem I had is that events needed pointers to the objects they affect and I do not know any way to check if pointers are actually valid in C. The...
0
by: april86 | last post by:
Hello everyone! I am new to C# and i have a question: I need to copy one Queue to another and i tried this: public static void copyQueues(Queue q, Queue q_copy) { Array...
2
by: manojmohadikar2008 | last post by:
Hi All, We are observing a serious issue with the memory usage of Queue and its very critical issue which needs to be fixed. We have an application which runs two threads i.e. a Producer and a...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.