Giter Club home page Giter Club logo

Comments (2)

jamesabel avatar jamesabel commented on August 20, 2024

I have what seems to be a similar problem.

Code:


import os
import time

from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler


class FileModifiedHandler(FileSystemEventHandler):

    def __init__(self, path):
        self.observer = Observer()
        self.observer.schedule(self, path, recursive=True)
        self.observer.start()

    def on_modified(self, event):
        print(event)

    def stop(self):
        self.observer.stop()
        self.observer.join()


def main(n):
    path = '.'
    fhs = [FileModifiedHandler(path) for _ in range(0, n)]
    time.sleep(2)
    with open(os.path.join(path, 'temp.txt'), 'w') as f:
        f.write('hi')
    time.sleep(2)
    [fh.stop() for fh in fhs]


if __name__ == '__main__':
    print('this works:')
    main(1)  # OK
    print('this fails:')
    main(2)  # fails

Output:

this works:
<FileModifiedEvent: src_path='./temp.txt'>
this fails:
<FileModifiedEvent: src_path='./temp.txt'>
2016-05-31 19:03 Python[63998] (FSEvents.framework) FSEventStreamStop(): failed assertion 'streamRef != NULL'

2016-05-31 19:03 Python[63998] (FSEvents.framework) FSEventStreamInvalidate(): failed assertion 'streamRef != NULL'

2016-05-31 19:03 Python[63998] (FSEvents.framework) FSEventStreamRelease(): failed assertion 'streamRef != NULL'

Traceback (most recent call last):
  File "/Users/james/projects/experiments/watchdog_experiment/watchdog_experiment.py", line 38, in <module>
    main(2)  # fails
  File "/Users/james/projects/experiments/watchdog_experiment/watchdog_experiment.py", line 31, in main
    [fh.stop() for fh in fhs]
  File "/Users/james/projects/experiments/watchdog_experiment/watchdog_experiment.py", line 31, in <listcomp>
    [fh.stop() for fh in fhs]
  File "/Users/james/projects/experiments/watchdog_experiment/watchdog_experiment.py", line 20, in stop
    self.observer.stop()
  File "/Users/james/projects/experiments/watchdog_experiment/venv/lib/python3.4/site-packages/watchdog/utils/__init__.py", line 99, in stop
    self.on_thread_stop()
  File "/Users/james/projects/experiments/watchdog_experiment/venv/lib/python3.4/site-packages/watchdog/observers/api.py", line 357, in on_thread_stop
    self.unschedule_all()
  File "/Users/james/projects/experiments/watchdog_experiment/venv/lib/python3.4/site-packages/watchdog/observers/api.py", line 353, in unschedule_all
    self._clear_emitters()
  File "/Users/james/projects/experiments/watchdog_experiment/venv/lib/python3.4/site-packages/watchdog/observers/api.py", line 230, in _clear_emitters
    for emitter in self._emitters:
ValueError: PyCapsule_GetPointer called with invalid PyCapsule object

Process finished with exit code 1

from watchdog.

BoboTiG avatar BoboTiG commented on August 20, 2024

Fixed sometime ago, added a test to ensure no regression in f3c7f84.

from watchdog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.