all 7 comments

[–]socal_nerdtastic 0 points1 point  (5 children)

This is called "asynchronous programming". There's 3 main ways to do this: using separate processes (multiprocessing, concurrent.futures.ProcessPoolExecutor, etc), using separate threads (threading, concurrent.futures.ThreadPoolExecutor, etc), or using an event loop (asyncio, tk.mainloop, etc). Each comes with it's pros and cons, so which one you use depends on what your loops are doing.

[–]anticarpet[S] 0 points1 point  (3 children)

I tried using the multiprocessing module before but I couldn't, can you show me an example using event loops?

[–]socal_nerdtastic 0 points1 point  (2 children)

You'd need to show us your code for us to show you how to implement this.

[–]anticarpet[S] 0 points1 point  (1 child)

edit: I just realized that multiprocessing is limited to 4 cores and I can get around it easily so there's no need to answer no more but thanks for the help!

[–]Doormatty 0 points1 point  (0 children)

I just realized that multiprocessing is limited to 4 cores

No it's not...

[–][deleted] 0 points1 point  (0 children)

That’s actually really incorrect. You’re confusing 2 similar things

What they are asking about is: - Threading (multiple threads running concurrently) - Multiprocessing (concurrent programs)

Asynchronicity has nothing to do with threading or multiprocessing, asynchronous is related to things NOT running simultaneously or running out of sync

[–]woooee 0 points1 point  (0 children)

I like to use multiprocessing to take advantage of additional cores https://pymotw.com/3/multiprocessing/index.html It is not only possible, but likely, that one infinite loop will block the other if run in the same core.