fastai / nbdev

Create delightful software with Jupyter Notebooks
https://nbdev.fast.ai/
Apache License 2.0
4.8k stars 484 forks source link

nbdev_test having issues because of Python caching modules #1370

Open loayshaqir1 opened 9 months ago

loayshaqir1 commented 9 months ago

No need to add example as the explanation of the issue is simple. nbdev_test uses up to 8 workers (threads) to run the tests, if we have a library called new_lib for example that its __init__ file has some global variables in it, if we have more than 8 tests, there will be a worker that will run more than one test, and because all the tests do import new_lib, that worker that runs more than one test won't import new_lib again and give the new test a fresh new environment as new_lib is already in sys.modules so because of Python caching modules it won't be imported again. you should do something that refreshes workers before assigning them new tests