IamRichter
IamRichter

Reputation: 15

Python process locks main program

So, I create a small program that uses flask to receive some requests and do a few things over selenium. All bits that deal with selenium are in another file that I tried to run first using a thread, and when it did not worked, a process. I believe that the problem is because I use a while true to keep my selenium working. The selenium part knows what to do because it keep checking the variable that I update from them flask part...

This is pretty much my main class that runs the selenium and them start flask, but it never start flask. It get locked on the .start().

if __name__ == "__main__":
    #   Logging
    log_format = '%(asctime)s [%(filename)s:%(lineno)d] %(message)s'
    logging.basicConfig(format=log_format,
                        level=logging.INFO,
                        stream=sys.stdout)
    #   Start Selenium
    browser = Process(target=selenium_file.run_stuff())
    browser.start()
    print('TEST')
    #   Flask
    app.run(debug=True)

Not really sure how I could solve this problem (if it's a problem)...

Upvotes: 0

Views: 46

Answers (1)

Eric Dörheit
Eric Dörheit

Reputation: 163

Exchange browser = Process(target=selenium_file.run_stuff()) with browser = Process(target=selenium_file.run_stuff)

You don't pass the function run_stuff but you already execute it and hence it blocks your program until run_stuff returns.

Upvotes: 2

Related Questions