Re: issues with Trellis event loops and threads

"Phillip J. Eby" <pje-Wh6+Hckhi6HFNGf7iClzIwC/[email protected]>
Newsgroups gmane.comp.python.peak
Message-ID <[email protected]>
At 05:46 PM 7/21/2008 +0300, Sergey Schetinin wrote:
>I also think there should be a way to use the actual current state in
>the other thread, but context.States just doesn't work that way. I see
>no reason why it has to be that way. The app can set up it's current
>state and then start an operation in a new thread, it's only natural
>to make sure it works in the same / child context, but with all the
>"states[get_indent()]" that wouldn't work at all. Am I missing
>something or is that a design defect?

ctx = State.get()

#... new thread

ctx.swap()

Bear in mind, however, that doing this is an incredibly, horrifically 
bad idea  and you should never actually do it, because most services 
aren't going to be sharable across threads.  Really, you should 
explicitly share those services that need to be -- and CAN be -- 
shared across threads.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.