Does the Python program have an effect on the program being executed when the source file is modified?

Source: Internet
Author: User
My Python program takes a long time to run, but sometimes I don't want to wait until the program is complete to modify the parameters, can you modify the source code while the program is executing, and then execute the new program? I don't know if this is feasible.

Reply content:

Have an effect, but very small.
The running program itself is not affected because it was automatically compiled into Python bytecode and ran in memory before it was run. Unless you call reload () in the program to reload the program, it will not affect the operation.
However, if the program has an error and throws an exception, it immediately reads from the current my Python source file and displays an error line. So the exception stack shows the running program error line number, as well as the current version of the latest source code. Looks a little split. You should use the command line arguments instead of modifying the program ... Then why do you want to put the parameters in the main py file?
Can't you write another file to set your parameters?
Check this parameter file periodically (e.g. Ini,csv,json)
Then change the program execution strategy. Also write a script to change the normal operation to first copy and then run, can you change the parameters in a multi-threaded way? Not very understanding. For this and the future operation, will not.
Remember to see @kyon N is an interesting answer,http//zhihu.com/question/39837216/answer/83451305

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.