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


Groups > comp.lang.python > #50138

AMQP listening and user-facing daemon

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <c.justin88@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
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; '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; 'received:google.com': 0.35; 'similar': 0.36; 'url:org': 0.36; 'should': 0.36; 'virtual': 0.37; 'feedback': 0.38; 'message-id:@gmail.com': 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; 'received:206': 0.63; '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
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=B2oIzy99owCkopVZ8JcoB5vo+zGNwEEaeHZbuTC6O2I=; b=k3M6EuhON//yptfOjg3vVW1JH8GhRDtuwCH2Zn9iD5/74B/OrrL7NOKG5va6koFAss 8Mr7AVaV430uljf/4PaJk24UZdnumal6gq0hHRtkpMtSzkYx6e1/0hdCtLrh3sJJ+I64 je4ANK9RUz00boeD6ceUkTqVwfTyRKE8XcP2UY50eDKYBqQwkXSqSBA2AuGbOiKOMXlj JsycxJ1FUeNdfbbCQUtPtM2BeuFO+7SXrhlJrYRR4lBVyazVOGxDmcVyifjlr9Ybzemh mI8eGrrg/51fVscWWXIyQ9FUSxasJCcyWEXbIMyUKF49JGiowbEXF8DsSplXblxZYoWm k2Uw==
X-Received by 10.66.145.4 with SMTP id sq4mr6298272pab.46.1373234280939; Sun, 07 Jul 2013 14:58:00 -0700 (PDT)
Date Sun, 07 Jul 2013 14:57:55 -0700
From Justin Chiu <c.justin88@gmail.com>
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-Mailman-Approved-At Mon, 08 Jul 2013 11:22:35 +0200
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.4376.1373275357.3114.python-list@python.org> (permalink)
Lines 48
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1373275357 news.xs4all.nl 15911 [2001:888:2000:d::a6]:48020
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:50138

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 <c.justin88@gmail.com> - 2013-07-07 14:57 -0700

csiph-web