Could it be how do I create the application?

bottle.default_app.push(web.app)

session_opts = {

        'session.cookie_expires': configuration["session"]["expires"],

        'session.encrypt_key': configuration["session"]["encrypt-key"],

        'session.httponly': True,

        'session.timeout': configuration["session"]["timeout"],

        'session.type': 'cookie',

        'session.validate_key': True,

}


application = SessionMiddleware(\

                             I18NMiddleware(\

                                            web.app,\

                                            I18NPlugin(domain='messages',\

                                                       default="en",\


locale_dir=os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
'./locale')))\

                                            ),\

                             session_opts)



where the is

   web.app = bottle.Bottle()


and I mount a lot of other bottle applications.





On Mon, Jan 27, 2014 at 10:21 AM, Pasithee Jupiter <[email protected]>wrote:

> the __del__ is never been called
>
> So I also tried uWSGI 2.0 (same issue)
>
> Then I tried to only add your while True and printing message in my Mailer
> class. But that does work.
>
>
>
>
> On Mon, Jan 27, 2014 at 10:08 AM, Roberto De Ioris <[email protected]>wrote:
>
>>
>> > Hi Roberto
>> >
>> > Your example works. Could it be that i use uWSGI 1.9 and not uWSGI 2.0?
>>
>> they are basically the same and there are no relevant bugfixes between
>> 1.9.17 and 2.0
>>
>> can you add a print in your __del__ method to check if it is called too
>> early ?
>>
>> >
>> >
>> >
>> > On Mon, Jan 27, 2014 at 9:50 AM, Roberto De Ioris <[email protected]>
>> > wrote:
>> >
>> >>
>> >> > maybe it would help. I use bottlepy as webframwork
>> >>
>> >>
>> >> this is a sample app based on your code:
>> >>
>> >> # bottiglia.py
>> >> from bottle import route, run, template, default_app
>> >> from threading import Thread
>> >> import time
>> >>
>> >> class Mailer(object):
>> >>
>> >>     def __init__(self):
>> >>         self._threads = []
>> >>
>> >>     def _send(self):
>> >>         while True:
>> >>             time.sleep(1)
>> >>             print "hello"
>> >>
>> >>     def send(self):
>> >>          thread = Thread(target=self._send)
>> >>          thread.daemon = True
>> >>          thread.start()
>> >>          self._threads.append(thread)
>> >>
>> >>     def join(self):
>> >>         return [t.join(5) for t in self._threads]
>> >>
>> >>     def __del__(self):
>> >>         self.join()
>> >>
>> >> @route('/hello/<name>')
>> >> def index(name):
>> >>     m = Mailer()
>> >>     m.send()
>> >>     return template('<b>Hello {{name}}</b>!', name=name)
>> >>
>> >> application = default_app()
>> >>
>> >>
>> >> i run it with
>> >>
>> >> uwsgi --http-socket :9090 -w bottiglia --enable-threads
>> >>
>> >> and after the request the thread is still alive.
>> >>
>> >> Can you check if it works for you ? (i am using uWSGI 2.0)
>> >>
>> >> --
>> >> Roberto De Ioris
>> >> http://unbit.it
>> >> _______________________________________________
>> >> uWSGI mailing list
>> >> [email protected]
>> >> http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
>> >>
>> > _______________________________________________
>> > uWSGI mailing list
>> > [email protected]
>> > http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
>> >
>>
>>
>> --
>> Roberto De Ioris
>> http://unbit.it
>> _______________________________________________
>> uWSGI mailing list
>> [email protected]
>> http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
>>
>
>
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to