maybe it would help. I use bottlepy as webframwork

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

> I simply create a new mailer instance
>
> mailer = Mailer(email_sender, smtp_url)
>
> and call later in my workflow
>
> mailer.send('[email protected]')
>
>
> What is the right approach?
>
>
>
>
>
> On Mon, Jan 27, 2014 at 9:25 AM, Roberto De Ioris <[email protected]>wrote:
>
>>
>> > Hi All
>> >
>> > I know it was asked a lot but after hours of searching and trying
>> several
>> > posts, I couldn't find any solution to create a "long running" thread.
>> >
>> > The problem is, that my thread stops working, as soon as the client
>> gets a
>> > response from the server.
>> >
>> > So what I have is the following:
>> >
>> >    - uwsgi == 1.9.17.1-debian
>> >    - nginx == 1.4.4 (Ubuntu)
>> >
>> >
>> > class Mailer(object):
>> >     self._threads = []
>> >
>> >     def send(self):
>> >          ...
>> >          thread = Thread(target=self._send, args=(email_addr,
>> > msg.as_string()))
>> >          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()
>> >
>> >
>>
>> Taking in account this is not the best approach for this specific problem,
>> how do you call the send method in the Mailer object from your WSGI
>> callable ?
>>
>> --
>> 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