Skip to content

Commit

Permalink
[windows] Fix event detection right after starting an emitter on PyPy (
Browse files Browse the repository at this point in the history
…#796)

And re-add PyPy to CI

Co-authored-by: Mickaël Schoentgen <[email protected]>
  • Loading branch information
oprypin and BoboTiG authored May 12, 2021
1 parent 4e7ca8d commit 50af6eb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ jobs:
name: Run tests for ${{ matrix.os }} for ${{ matrix.python }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python: [3.6, 3.7, 3.8, 3.9]
python: [3.6, 3.7, 3.8, 3.9, pypy3]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Changelog

2021-xx-xx • `full history <https://github.com/gorakhargosh/watchdog/compare/v2.1.2...master>`__

-
- Thanks to our beloved contributors: @
- [windows] On PyPy, events happening right after ``start()`` were missed. Add a workaround for that. (`#796 <https://github.com/gorakhargosh/watchdog/pull/796>`_)
- Thanks to our beloved contributors: @oprypin

2.1.1
~~~~~
Expand Down
7 changes: 7 additions & 0 deletions src/watchdog/observers/read_directory_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import threading
import os.path
import time
import platform

from watchdog.events import (
DirCreatedEvent,
Expand Down Expand Up @@ -65,6 +66,12 @@ def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT):
def on_thread_start(self):
self._handle = get_directory_handle(self.watch.path)

if platform.python_implementation() == 'PyPy':
def start(self):
"""PyPy needs some time before receiving events, see #792."""
super().start()
time.sleep(0.01)

def on_thread_stop(self):
if self._handle:
close_directory_handle(self._handle)
Expand Down

0 comments on commit 50af6eb

Please sign in to comment.