473,324 Members | 2,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

passing data to a daemon

Hi all.

I want to run a Python daemon that manages a "to-do" queue. I want it
so that the daemon is always running, where its running consists of
looking at the queue to see if it has any jobs, and if it does, remove
the job from the queue and "do the job".

This all seems quite doable using the synchronized Queue.py module and
this page
(http://aspn.activestate.com/ASPN/Coo...n/Recipe/66012) which
describes writing a daemon in Python.

My problem is: how will I submit jobs to the queue? The issue is that
jobs are generated by users of, say, the operating system, so they
aren't a part of the daemon process. Ideally, I want a way of making a
function call to the daemon process *from outside the daemon process*.

For example, say my daemon has the function in it "addToQueue". I'd
like to write a totally separate piece of Python code that calls this
function inside the *running* daemon.

I suppose I could use files with locking as an interface, but there's
got to be a better way.

Thanks for any tips,

Rob
Jul 18 '05 #1
3 5615
there are a number of ways you could do this, ranging from sending a message
to the daemon over a socket (probably using the select() function) or using
a higher layer remote method invocation or object broker library. the
twisted project (http://www.twistedmatrix.com/) seems to provide some
useful utilities for this. others you might consider are zope
(http://www.zope.org) or pyro (http://pyro.sourceforge.net). i don't have
much experience with any of these but hopefully you'll find something
useful.

later,

gene

Rob Hunter wrote:
Hi all.

I want to run a Python daemon that manages a "to-do" queue. I want it
so that the daemon is always running, where its running consists of
looking at the queue to see if it has any jobs, and if it does, remove
the job from the queue and "do the job".

This all seems quite doable using the synchronized Queue.py module and
this page
(http://aspn.activestate.com/ASPN/Coo...n/Recipe/66012) which
describes writing a daemon in Python.

My problem is: how will I submit jobs to the queue? The issue is that
jobs are generated by users of, say, the operating system, so they
aren't a part of the daemon process. Ideally, I want a way of making a
function call to the daemon process *from outside the daemon process*.

For example, say my daemon has the function in it "addToQueue". I'd
like to write a totally separate piece of Python code that calls this
function inside the *running* daemon.

I suppose I could use files with locking as an interface, but there's
got to be a better way.

Thanks for any tips,

Rob


Jul 18 '05 #2
In article <ma*********************************@python.org> , Rob Hunter wrote:
Hi all.

I want to run a Python daemon that manages a "to-do" queue. I want it
so that the daemon is always running, where its running consists of
looking at the queue to see if it has any jobs, and if it does, remove
the job from the queue and "do the job".

This all seems quite doable using the synchronized Queue.py module and
this page
(http://aspn.activestate.com/ASPN/Coo...n/Recipe/66012) which
describes writing a daemon in Python.

My problem is: how will I submit jobs to the queue? The issue is that
jobs are generated by users of, say, the operating system, so they
aren't a part of the daemon process. Ideally, I want a way of making a
function call to the daemon process *from outside the daemon process*.

For example, say my daemon has the function in it "addToQueue". I'd
like to write a totally separate piece of Python code that calls this
function inside the *running* daemon.

I suppose I could use files with locking as an interface, but there's
got to be a better way.

Files are one way. Sockets another. Make it listen on a socket
and accept commands from it, write a client that connects
to and send commands/data to it. If you're on *nix, use
unix sockets. Higher level API's over sockets can also be used,
e.g. xml-rpc or corba.

Jul 18 '05 #3
Rob Hunter wrote:
My problem is: how will I submit jobs to the queue? The issue is that
jobs are generated by users of, say, the operating system, so they
aren't a part of the daemon process. Ideally, I want a way of making a
function call to the daemon process *from outside the daemon process*.

For example, say my daemon has the function in it "addToQueue". I'd
like to write a totally separate piece of Python code that calls this
function inside the *running* daemon.


Use Pyro (http://pyro.sourceforge.net)
With only a few (3 to 4) extra lines in your code you're able
to call methods in different Python processes just as if
it was a 'local' method. No network programming needed at all.

Good luck
--Irmen de Jong

Jul 18 '05 #4

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

Similar topics

3
by: bmgx | last post by:
This is what I am trying to find out, instruction on how to create a simple daemon on unix systems(Linux), can't find any info on usual sources..
1
by: Bob Swerdlow | last post by:
I've created a Python daemon that starts a bunch of BitTorrent downloader process. Everything is working fine when I start the daemon by hand (logged on as root). I can quit the session and see...
11
by: Mike M | last post by:
Is it possible? In the parent process, I have a socket that binds, listens and then accepts new connections (which creates new sockets in the process). I want to be able to pass some of these new...
7
by: Michael Ransburg | last post by:
Hi! I have implemented a daemon in C++. It runs all the time, between reboots. Is there a way for other C++ classes to get a reference to the instance of this daemon class in order to call its...
10
by: Ramprasad A Padmanabhan | last post by:
Hello all, On my linux box ( redhat 7.2 ), I have been using char as a boolean data type. In order to save on the number of bytes as compared to using int or short int. typedef char boolean;...
1
by: Stefan Neumann | last post by:
I have written a daemon which should run endlessly. The structure looks like this: - start-stop-daemon forks my python program then: if __name__=="__main__": try: main()
28
by: Skeets | last post by:
i'm passing session and hidden variables between pages. not to mention post values. i'm a little concerned that someone with sufficient knowledge could spoof these vlaues and manipulate the...
6
by: Johny | last post by:
Is it possible to run a Python program as daemon? Thanks
13
dmjpro
by: dmjpro | last post by:
class MainClass{ public static void main(String a){ //do something } } When i run this class file then JVM is the process having one main thread. Thread ends and process ends. I went...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.