-
-
Notifications
You must be signed in to change notification settings - Fork 704
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
macOS: TypeError: PyCObject_AsVoidPtr called with null pointer #541
Comments
(edited example to shorten) |
The traceback doesn't point at the implementation of watchdog_stop in watchdog_fsevents.c but that seems to be where the problem arises. It's not in the traceback because there's no check for an error result from |
When the watched directory is deleted the emitter thread for it exits (read_events raises OSError(ENOENT)). Then later when the watch is unscheduled there is no event loop running for it anymore, thus the If I change
to avoid the stop/join if it is already stopped then the exception goes away. |
Hello @exarkun, Thanks for the analysis 👍 |
I looked around for tests for Observer behavior but I didn't find a module that looked suitable. Do you have any suggestions about where a test for this should go? |
I will have a look this weekend ;) |
ping |
A test should go into |
Sure, that'd be great. |
OK it should be just fine like that: From 7f5b5af0b3de37445f95be293967427d3b1a66e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= <contact@tiger-222.fr>
Date: Tue, 19 Mar 2019 15:25:38 +0100
Subject: [PATCH] Add test case
---
tests/test_fsevents.py | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/tests/test_fsevents.py b/tests/test_fsevents.py
index f0d80066..c37797c6 100644
--- a/tests/test_fsevents.py
+++ b/tests/test_fsevents.py
@@ -8,8 +8,11 @@
import logging
import os
+import time
from functools import partial
+from os import mkdir, rmdir
+from watchdog.observers import Observer
from watchdog.observers.api import ObservedWatch
from watchdog.observers.fsevents import FSEventsEmitter
@@ -41,6 +44,17 @@ def start_watching(path=None, use_full_emitter=False):
emitter.start()
+@pytest.fixture
+def observer():
+ obs = Observer()
+ yield obs
+ obs.stop()
+ try:
+ obs.join()
+ except RuntimeError:
+ pass
+
+
def test_remove_watch_twice():
"""
ValueError: PyCapsule_GetPointer called with invalid PyCapsule object
@@ -63,3 +77,25 @@ def on_thread_stop(self):
emitter.stop()
# This is allowed to call several times .stop()
emitter.stop()
+
+
+def test_unschedule_removed_folder(observer):
+ """
+TypeError: PyCObject_AsVoidPtr called with null pointer
+The above exception was the direct cause of the following exception:
+
+def on_thread_stop(self):
+ if self.watch:
+ _fsevents.remove_watch(self.watch)
+E SystemError: <built-in function stop> returned a result with an error set
+
+(FSEvents.framework) FSEventStreamStop(): failed assertion 'streamRef != NULL'
+(FSEvents.framework) FSEventStreamInvalidate(): failed assertion 'streamRef != NULL'
+(FSEvents.framework) FSEventStreamRelease(): failed assertion 'streamRef != NULL'
+ """
+ a = p("a")
+ mkdir(a)
+ w = observer.schedule(event_queue, a, recursive=False)
+ rmdir(a)
+ time.sleep(0.1)
+ observer.unschedule(w) |
On macOS this program fails:
with this traceback:
The text was updated successfully, but these errors were encountered: