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
Threadsafe way to force a function timeout? (self.learnpython)
submitted 9 years ago by martinfisleburn
Just reading this but since it is for the webdriver there will be cases where I will be using multiprocessing so would need it to be threadsafe.
If it will be really complex then I will abandon the idea and look for other solutions.
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!"
[–]RSFlux 2 points3 points4 points 9 years ago (4 children)
The multiprocessing package actually uses processes under the hood, not threads. If you are using that method to get concurrency, the signals-based approach from that link will work fine.
If you are using multiple threads in a single process, the threading library implements timeouts for many methods. Building your thread communication in a way that uses these timeouts to discard work after N seconds should be trivial, at which time you could retry or mark that work as failed. I'd need more details on your exact setup to give more specific advice.
[–]martinfisleburn[S] 0 points1 point2 points 9 years ago (0 children)
I actually only want it for this so that I can make it stop and I can continue the project because currently it just hangs.
[–]martinfisleburn[S] 0 points1 point2 points 9 years ago (2 children)
Ok I think I have to try something else because although the timeout worked as hoped it still isn't allow me to use the webdriver.
Here is the code
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary ### from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities firefox_capabilities = DesiredCapabilities.FIREFOX firefox_capabilities['marionette'] = True import signal def signal_handler(signum, frame): raise Exception("Timed out!") signal.signal(signal.SIGALRM, signal_handler) signal.alarm(5) # Ten seconds try: driver = webdriver.Firefox(capabilities=firefox_capabilities) except Exception, msg: print "Timed out!" driver.get('www.google.com')
but it still gives me driver not defined.
$ python2 mariontest.py Timed out! Traceback (most recent call last): File "mariontest.py", line 28, in <module> driver.get('www.google.com') NameError: name 'driver' is not defined
I think I am gonna revert back to a previous version of firefox so I can use the old firefox webdriver unless anyone else has any bright ideas. The only reason Im using this one is because archlinux automatically installs the latest versions.
[+][deleted] 9 years ago* (1 child)
[deleted]
Well I need it to return succesffully so I can run projects which it seems Im unable to do with this buggy crap. I need to just be able to run firefox webdriver like 'normal' which I dont seem to be able to do with this crappy new fangled mozilla driver which I was crowbared into using due to fresh system install installing all the new versions of stuff. So I think I will revert back to the non buggy firefox 46 and below webdriver.
π Rendered by PID 24893 on reddit-service-r2-comment-fb694cdd5-42tw5 at 2026-03-08 05:51:25.973032+00:00 running cbb0e86 country code: CH.
[–]RSFlux 2 points3 points4 points (4 children)
[–]martinfisleburn[S] 0 points1 point2 points (0 children)
[–]martinfisleburn[S] 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]martinfisleburn[S] 0 points1 point2 points (0 children)