It's interesting that the mere use of threading does not break anything in pyglet's consistency as its own event loop's source reads a little like it assumes that none of its function calls would be preempted ― whereas python threading might be preempting function calls all of the time as it juggles the threads (or does it?).
Anyone care to comment? On Friday, October 2, 2020 at 1:58:20 PM UTC+3 chris....@googlemail.com wrote: > OK, thank you very muc for that. > > I need to learn about asyncio before I can even understand that code, but > it looks about what I was expecting. > > Hopefully if I can learn more about it, I can make some version of > pyglet's event loop that'll cooperate nicely, but that'll do in the > meantime. Thank you. > > Take care, > > Chris Norman > > > > On Fri, 2 Oct 2020 at 10:14, ryannathans <ryann...@hotmail.com> wrote: > >> I have a thread for all async stuff (eg networking) and run pyglet on the >> main thread (because windows seems to have problems if you run it in >> another thread - linux is ok with it though). >> >> for example >> >> def run(self): >> with concurrent.futures.ThreadPoolExecutor() as thread_pool: >> #submit networking/async stuff to thread_pool >> try: >> pyglet.app.run() >> finally: >> #tell networking thread to shutdown >> atexit.unregister(concurrent.futures.thread._python_exit) # >> helps the program exit cleanly if there are blocking reads in threads that >> will never complete >> >> I don't know if this is the "right way" but it works for me - just keep >> all the async in one thread and communicate with it in a threadsafe manner >> On Friday, 2 October 2020 at 5:32:21 am UTC+10 chris....@googlemail.com >> wrote: >> >>> Hi all, >>> Is there an officially-supported way to use asyncio from within Pyglet? >>> >>> If not, what's the recommended way to do networking with Pyglet? >>> >>> Thanks in advance. >>> >>> Take care, >>> >>> Chris Norman >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "pyglet-users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to pyglet-users...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/pyglet-users/7cb132dc-3f3b-4e27-993f-7ad78f24f83an%40googlegroups.com >> >> <https://groups.google.com/d/msgid/pyglet-users/7cb132dc-3f3b-4e27-993f-7ad78f24f83an%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "pyglet-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/pyglet-users/8525d7c9-7d93-42e6-8a66-33964d7a8fdfn%40googlegroups.com.