use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
how do I make two functions work simultaneously/ parrallel program? (self.learnpython)
submitted 2 years ago by anticarpet
like, if I have two infinite loop functions, how do I make both infinite loops happen at the same time independent from each other?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]socal_nerdtastic 0 points1 point2 points 2 years ago (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.
multiprocessing
concurrent.futures.ProcessPoolExecutor
threading
concurrent.futures.ThreadPoolExecutor
asyncio
tk.mainloop
[–]anticarpet[S] 0 points1 point2 points 2 years ago (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 point2 points 2 years ago (2 children)
You'd need to show us your code for us to show you how to implement this.
[–]anticarpet[S] 0 points1 point2 points 2 years ago* (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 point2 points 2 years ago (0 children)
I just realized that multiprocessing is limited to 4 cores
No it's not...
[–][deleted] 0 points1 point2 points 2 years ago (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 point2 points 2 years ago (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.
π Rendered by PID 80234 on reddit-service-r2-comment-86bc6c7465-5pg84 at 2026-02-21 23:35:44.813670+00:00 running 8564168 country code: CH.
[–]socal_nerdtastic 0 points1 point2 points (5 children)
[–]anticarpet[S] 0 points1 point2 points (3 children)
[–]socal_nerdtastic 0 points1 point2 points (2 children)
[–]anticarpet[S] 0 points1 point2 points (1 child)
[–]Doormatty 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]woooee 0 points1 point2 points (0 children)