> hello, > > i tend to use uWSGI for nearly everything, even very basic or > one-time-use applications, simply because it solves many problems and > offers features that said apps. > > one problem i've had for awhile now is how to properly run apps that > require no incoming --socket, or really, an uWSGI-managed event loop > of any kind... recent examples: > > ) AMQP consumer/worker > ) team-oriented IRC bot > ) vpython realtime analyzer/demonstration > > ... is there any way to run such applications in a natural way? > currently i run them as mules, and set `--processes=0` in addition to > `--socket=@null` (or some variant). while this works well enough it's > really more of a hack, and in this specific case i'd like to use the > tracebacker but that doesn't seem to work on mules. i've also tried > using `--command-mode` but that has nasty side effects like not > processing touch-reloads, and `--worker-exec` means no services at all > :( > > essentially i want uWSGI to neither care nor require an explicit loop, > and expect workers to block on their own... and the end of the day i > potentially want to use any of the services uWSGI has to offer > (general-purpose application container) *EXCEPT* > parsing/handling/delegating an "incoming stream"... seeking a "noop > loop" if-you-will. > > ...thoughts? loop-engine/plugin required (if possible at all)? > >
You may want to try this plugin: https://github.com/unbit/uwsgi/blob/master/plugins/dumbloop/dumb.c with latest code, specifying a loop wngine (with --loop) forces uWSGI to ignore sockets presence (a user using --loop should know what he is doing). The un-socketed workers will simply run a function as soon as they are ready. The whole uWSGI api is available (as well as the tracebacker, locking and so on) You can write a simple multithreaded app: import uwsgi import time def dumbloop(core): while True: uwsgi.lock() print "i am core %s on worker %d" % (core, uwsgi.worker_id()) uwsgi.unlock() time.sleep(1) (save it as uwsgi_dumbloop.py) uwsgi --master --processes 4 --threads 8 --plugin dumbloop --loop dumb The dumbloop plugin will search for a uwsgi_dumbloop "module" and a dumbloop function but you can specify custom modules,functions and modifiers using the options supplied by the dumbloop plugin (see the sources). This function takes the core number (as a string) as the only argument. -- Roberto De Ioris http://unbit.it _______________________________________________ uWSGI mailing list [email protected] http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
