-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RuntimeError: Cannot add watch, already scheduled #73
Comments
Hey, That's look very relevant! Thank you for reaching out. Anyway to produce the full stack trace, pointing to a code line in It sounds like this will be hard to reproduce to test correctly. |
I get that error with my flask server from time to time, I don't have more details:
(On macOS, python 3.9) |
This seems to pop-up every now and then when I use multiple process to access the same cache value, but unable to reproduce consistently. |
I can always reproduce the error on mac intel 12.7 using the latest cachier 2.2.2 and Python 3.11.1 with this script: import logging
import threading
import time
from cachier import cachier
@cachier()
def func(x):
logging.info("Calculating %s", x)
time.sleep(1)
return x * x
def thread_function(name):
logging.info("Thread %s: starting", name)
func(1234)
logging.info("Thread %s: finishing", name)
def main():
format = "%(asctime)s: %(message)s"
logging.basicConfig(format=format, level=logging.INFO, datefmt="%H:%M:%S")
func.clear_cache()
threads = []
for index in range(3):
logging.info("Main : create and start thread %d.", index)
x = threading.Thread(target=thread_function, args=(index,))
threads.append(x)
x.start()
for index, thread in enumerate(threads):
logging.info("Main : before joining thread %d.", index)
thread.join()
logging.info("Main : thread %d done", index)
if __name__ == "__main__":
main() Output (the script hangs and I need to hit Ctrl-C):
Packages installed in the virtualenv:
I don't get the error in any of these cases:
|
Killing (CTRL-C) a long running cached function mid-miss can readily reproduce this. |
Thank you both for chiming in, and @GianlucaFicarelli especially for the very detailed way to reproduce this! This dramatically increases the chance that a past active contributor or a new one will take this on and try to solve this bug. |
It seems that when running cachier, I randomly get these errors:
My current solution is to delete the cache, assuming it is corrupt, and then start from scratch.
The most similar error I found on the net was the one reported in spyder-ide/spyder#14803. There, the solution was to unwatch on switching directories/projects.
The text was updated successfully, but these errors were encountered: