Hi, as 'new process' do you mean I should rewrite notification part to separate .py file, add in development.ini new application (for example [app:notifications] and run it separately from main app? Thanks for reply.
Regards, Radek Pozdrawiam, Radosław Trojanowski 2013/8/29 Michael Merickel <[email protected]> > Your worker should be a separate process, run as a script. When run > individually you have very simple control over how many wsgi servers and > how many workers you are running. They really have no business being > coupled. > > Of course you could hack it with some CLI flag passed into your INI file. > > [app:main] > ... > spawn_worker = %(spawn_worker)s > > paster serve my.ini spawn_worker=true > paster serve my.ini spawn_worker=false > > But really, just make it a separate process. > > - Michael > > > On Thu, Aug 29, 2013 at 4:55 AM, Radosław Trojanowski < > [email protected]> wrote: > >> Hello guys, >> >> I have got little problem during developing notification functionality in >> Pylons-based application. >> We use multi-server configuration with 4 Paste servers (with 10-threads >> threadpool for each server). >> I decided to implement is as background thread which through scheduler >> runs check for notifications every minute. >> >> in Python script I imported: >> >> *import thread, threading* >> >> >> and in main make_app function added following: >> >> *thread.start_new_thread(timingforalerts, (app_globals, config, ))* >>> *#creates separate thread for searching pending alerts* >> >> >> *timingforalerts()* is my function which queries database for pending >> alerts and if any are found sends notifications through e-mail/jabber. >> >> *PROBLEM* is that this thread is started on EACH server, so that means >> there are FOUR threads created for searching alerts. It affects that when >> notification is found user receives four email or four Jabber messages. >> >> Please help me figure out how to start thread only on one server (for >> example only on server:main). >> >> Configuration in development.ini looks following: >> >> *[server:main]* >> use = egg:Paste#http >> host = 127.0.0.1 >> port = 5000 >> use_threadpool = True >> threadpool_workers = 10 >> >> *[server:main2]* >> use = egg:Paste#http >> host = 127.0.0.1 >> port = 5001 >> use_threadpool = True >> threadpool_workers = 10 >> >> *[server:main3]* >> use = egg:Paste#http >> host = 127.0.0.1 >> port = 5002 >> use_threadpool = True >> threadpool_workers = 10 >> >> *[server:main4]* >> use = egg:Paste#http >> host = 127.0.0.1 >> port = 5003 >> use_threadpool = True >> threadpool_workers = 10 >> >> -- >> You received this message because you are subscribed to the Google Groups >> "pylons-discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/pylons-discuss. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- > You received this message because you are subscribed to a topic in the > Google Groups "pylons-discuss" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/pylons-discuss/-7ZIlMAjKhk/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/pylons-discuss. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/pylons-discuss. For more options, visit https://groups.google.com/groups/opt_out.
