@@ -41,47 +41,55 @@ def __init__(self: "Handler", **kwargs: Any) -> None:
41
41
RegexMatchingEventHandler .__init__ (self , ** kwargs )
42
42
43
43
def on_created (self : "Handler" , event : FileSystemEvent ) -> None :
44
- loop .call_soon_threadsafe (
45
- queue .put_nowait ,
46
- {
47
- "change" : "created" ,
48
- "src_path" : event .src_path ,
49
- "type" : event .__class__ .__name__ ,
50
- "root_path" : root_path ,
51
- },
44
+ asyncio .run_coroutine_threadsafe (
45
+ queue .put (
46
+ {
47
+ "change" : "created" ,
48
+ "src_path" : event .src_path ,
49
+ "type" : event .__class__ .__name__ ,
50
+ "root_path" : root_path ,
51
+ },
52
+ ),
53
+ loop ,
52
54
)
53
55
54
56
def on_deleted (self : "Handler" , event : FileSystemEvent ) -> None :
55
- loop .call_soon_threadsafe (
56
- queue .put_nowait ,
57
- {
58
- "change" : "deleted" ,
59
- "src_path" : event .src_path ,
60
- "type" : event .__class__ .__name__ ,
61
- "root_path" : root_path ,
62
- },
57
+ asyncio .run_coroutine_threadsafe (
58
+ queue .put (
59
+ {
60
+ "change" : "deleted" ,
61
+ "src_path" : event .src_path ,
62
+ "type" : event .__class__ .__name__ ,
63
+ "root_path" : root_path ,
64
+ },
65
+ ),
66
+ loop ,
63
67
)
64
68
65
69
def on_modified (self : "Handler" , event : FileSystemEvent ) -> None :
66
- loop .call_soon_threadsafe (
67
- queue .put_nowait ,
68
- {
69
- "change" : "modified" ,
70
- "src_path" : event .src_path ,
71
- "type" : event .__class__ .__name__ ,
72
- "root_path" : root_path ,
73
- },
70
+ asyncio .run_coroutine_threadsafe (
71
+ queue .put (
72
+ {
73
+ "change" : "modified" ,
74
+ "src_path" : event .src_path ,
75
+ "type" : event .__class__ .__name__ ,
76
+ "root_path" : root_path ,
77
+ },
78
+ ),
79
+ loop ,
74
80
)
75
81
76
82
def on_moved (self : "Handler" , event : FileSystemEvent ) -> None :
77
- loop .call_soon_threadsafe (
78
- queue .put_nowait ,
79
- {
80
- "change" : "moved" ,
81
- "src_path" : event .src_path ,
82
- "type" : event .__class__ .__name__ ,
83
- "root_path" : root_path ,
84
- },
83
+ asyncio .run_coroutine_threadsafe (
84
+ queue .put (
85
+ {
86
+ "change" : "moved" ,
87
+ "src_path" : event .src_path ,
88
+ "type" : event .__class__ .__name__ ,
89
+ "root_path" : root_path ,
90
+ },
91
+ ),
92
+ loop ,
85
93
)
86
94
87
95
observer = Observer ()
0 commit comments