Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #50020

AMQP listening and user-facing daemon

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <j.chiu@cern.ch>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'output': 0.05; '[1]:': 0.09; '[2]:': 0.09; '[3]:': 0.09; 'executes': 0.09; 'http': 0.09; 'parsed': 0.09; 'parsing': 0.09; 'sfxlen:2': 0.11; 'python': 0.11; 'template': 0.14; '[4]:': 0.16; 'concurrent': 0.16; 'justin': 0.16; 'log.': 0.16; 'seconds,': 0.16; 'subject:user': 0.16; 'url:shtml': 0.16; 'wsgi': 0.16; 'all,': 0.19; 'server,': 0.19; 'command': 0.22; 'machine': 0.22; 'programming': 0.22; 'header:User-Agent:1': 0.23; 'driven': 0.24; 'manager.': 0.24; 'module,': 0.24; 'parse': 0.24; '(or': 0.24; 'script': 0.25; 'query': 0.26; 'post': 0.26; 'received:24': 0.27; 'to:2**1': 0.27; 'appreciated.': 0.29; 'to:no real name:2**1': 0.29; 'xml': 0.29; 'requests': 0.31; 'url:wiki': 0.31; 'continually': 0.31; 'run': 0.32; 'to:addr:tutor': 0.33; 'url:python': 0.33; '(e.g.': 0.33; 'info': 0.35; 'similar': 0.36; 'url:org': 0.36; 'should': 0.36; 'virtual': 0.37; 'feedback': 0.38; 'thank': 0.38; 'manager': 0.38; 'checks': 0.38; 'url:library': 0.38; 'writes': 0.38; 'skip:[ 10': 0.38; 'to:addr :python-list': 0.38; 'resource': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'read': 0.60; 'simple': 0.61; 'you.': 0.62; 'skip:n 10': 0.64; 'different': 0.65; 'messaging': 0.68; 'receive': 0.70; 'address,': 0.75; 'analysis': 0.75; 'details:': 0.80; 'listens': 0.84; 'url:trac': 0.84; 'procedural': 0.91; 'url:latest': 0.91
Date Fri, 5 Jul 2013 13:53:20 -0700
From Justin Chiu <j.chiu@cern.ch>
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:17.0) Gecko/20130620 Thunderbird/17.0.7
MIME-Version 1.0
To <python-list@python.org>, <tutor@python.org>
Subject AMQP listening and user-facing daemon
Content-Type text/plain; charset="ISO-8859-1"; format=flowed
Content-Transfer-Encoding 7bit
X-Originating-IP [24.68.137.213]
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4313.1373057673.3114.python-list@python.org> (permalink)
Lines 48
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1373057673 news.xs4all.nl 15881 [2001:888:2000:d::a6]:44848
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:50020

Show key headers only | View raw


Hi all,

What is the best approach to writing a concurrent daemon that can 
execute callbacks for different types of events (AMQP messages, parsed 
output of a subprocess, HTTP requests)?

I am considering [twisted][1], the built-in [threading][2] module, and 
[greenlet][3]. I must admit that I am very unfamiliar with concurrent 
programming and Python programming in general (formerly a data analysis 
driven procedural programmer). Any resources on threaded/concurrent 
programming (specifically daemons...not just multi-threading a single 
task) would be much appreciated.

Thank you.

Details:

1) Listens into AMQP messaging queues and executes callbacks when 
messages arrive.
Example: Immediately after startup, the daemon continuously listens to 
the [Openstack Notifications messaging queue][4]. When a virtual machine 
is launched, a notification is generated by Openstack with the hostname, 
IP address, etc. The daemon should read this message and write some info 
to a log (or POST the info to a server, or notify the user...something 
simple).

2) Parse the output of a subprocess and execute callbacks based on the 
output.
Example: Every 30 seconds, a system command "[qstat][5]" is run to query 
a job resource manager (e.g. TORQUE). Similar callbacks to 1).

3) Receive requests from a user and process them. I think this will be 
via WSGI HTTP.
Example: User submits an XML template with virtual machine templates. 
The daemon does some simple XML parsing and writes a job script for the 
job resource manager. The job is submitted to the resource manager and 
the daemon continually checks for the status of the job with "qstat" and 
for messages from AMQP. It should return "live" feedback to the user and 
write to a log.

   [1]: https://twistedmatrix.com/trac/wiki/Documentation
   [2]: http://docs.python.org/2/library/threading.html
   [3]: http://greenlet.readthedocs.org/en/latest/
   [4]: 
https://wiki.openstack.org/wiki/NotificationEventExamples#Immediate_Notifications:
   [5]: http://www.clusterresources.com/torquedocs21/commands/qstat.shtml

Justin Chiu            TRIUMF

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

AMQP listening and user-facing daemon Justin Chiu <j.chiu@cern.ch> - 2013-07-05 13:53 -0700

csiph-web