Access Object From 2 Applications or Fix Scheduler

Robert Rawlins - Think Blue robert.rawlins at thinkbluemedia.co.uk
Mon Jul 16 05:04:07 EDT 2007


Also Hendrik,

I should probably mention that the second application is a constant running
application, it's nothing something that can just be 'started' by the first
one, its running non-stop and just needs data passed into it regularly when
the first application finds it.

Application 1						Application 2
							Work with dict
							Work with dict
							Work with dict
							Work with dict
New XML Found, Parse Into Dict -------------->	Work with new dict
							Work with new dict
							Work with new dict
							Work with new dict

You see how that works? Application 1 has a function that runs every minute
and _may_ find a new xml file, if it does then I need it to parse that file
into a list of dictionary and then pass that into application 2, which then
starts using it :-)

Now we may be able to avoid this if there is some type of file watcher
function available in python, my second application could then just watch
the XML file and as soon as a new one is available parse it itself. Is that
something you've heard of?

Thanks,

Rob
							

-----Original Message-----
From: python-list-bounces+robert.rawlins=thinkbluemedia.co.uk at python.org
[mailto:python-list-bounces+robert.rawlins=thinkbluemedia.co.uk at python.org]
On Behalf Of Hendrik van Rooyen
Sent: 16 July 2007 07:29
To: python-list at python.org
Subject: Re: Access Object From 2 Applications or Fix Scheduler

 Robert Rawlins - Think Blue  wrote:


>Hello Guys,
>
>I have two applications which I need to get talking and sharing an 
>object, what
s the best way to do this? Basically my >first application parses an XML
document into a bunch of lists and tuples etc, and I need to access the data
in these lists >and tuples from my second application. Is this possible? And
whats the simplest method?

>
>This problem all evolves from a hack/work around Ive had to place 
>together as
I have been having problems with >sched, these two applications used to be a
single one to start with but for some reason when scheduling tasks using the
>sched module they wouldnt ever run when supposed too, so Id schedule 
>it to
run every 2 minutes and it would run >between 3 and 15 minutes :-s so I
ripped it out into its own application and it now runs every 2 minutes
exactly.
>
>I either need to fix my sched issues or the memory share, either way 
>Im quite
happy, just need to get it working >smoothly.
>
>Any ideas?
>

You have already split the thing, so I would:

schedule the XML parser and make it do its stuff.
then pickle the results using cPickle
then from this first thing, either:
write the pickles to temp files and start the second thing using eg
os.system() or start the second thing and use a named pipe to pass the
pickles over for unpickling and processing, or use one of the popens, or
have a look at Pyro, or start the second thing as a thread and use a Queue..

of course this whole scheme will fall apart if the combined processing takes
longer than the scheduling interval.

HTH - Hendrik






More information about the Python-list mailing list