Skip to content

Commit

Permalink
Using libev watchers means we need to sleep longer.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Sep 7, 2021
1 parent 50362d1 commit a82030f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/nti/mailer/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,14 @@ def _stat_watcher_modified(watcher):
# XXX: This can fail (false negative) if modifications are coming
# in faster than the resolution of the mtime, which depends on the
# gevent loop in use, as well as the filesystem and possibly
# the configuration.
# the configuration. This is easily observed on GitHub Actions
# with both watchers; our writing process has to sleep to allow
# the modification times to appear to change.
# XXX: Moreover, the very act of processing the queue will probably cause
# the watcher to fire. We should probably stop the watcher while
# processing the queue.
print("Prev time", _stat_modified_time(watcher.prev))
print("Attr time", _stat_modified_time(watcher.attr))
return _stat_modified_time(watcher.prev) != _stat_modified_time(watcher.attr)


Expand Down
6 changes: 4 additions & 2 deletions src/nti/mailer/tests/test_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,10 @@ def q():
self._queue_two_messages()
# Sleep (blocking) in case our stat watcher has
# very poor mtime resolution; we don't want a false
# negative in our detection.
time.sleep(0.5)
# negative in our detection. For libuv watchers,
# 0.5 seems to be enough. But for libev watchers on GHA,
# we need a full second.
time.sleep(1.0)

gevent.spawn(q)

Expand Down

0 comments on commit a82030f

Please sign in to comment.