File tree 2 files changed +2
-9
lines changed
2 files changed +2
-9
lines changed Original file line number Diff line number Diff line change 1
1
# 通用数据结构
2
- VERSION = '0.2.1 '
2
+ VERSION = '0.2.2 '
3
3
4
4
5
5
class AnonError (Exception ):
Original file line number Diff line number Diff line change 1
1
import asyncio
2
- import threading
3
2
from typing import List , Type
4
3
5
4
import aiocron
9
8
from .logger import logger
10
9
11
10
12
- class CronThread ( threading . Thread ) :
11
+ class CronThread :
13
12
loop : asyncio .AbstractEventLoop
14
13
tasks = set ()
15
14
16
15
def __init__ (self , loop ):
17
16
super ().__init__ ()
18
17
self .loop = loop
19
- self .start ()
20
18
21
19
def add_cron (self , cron : str , func , * args ):
22
20
async def wrapper ():
@@ -26,10 +24,6 @@ async def wrapper():
26
24
task = aiocron .crontab (cron , func = wrapper , loop = self .loop )
27
25
self .tasks .add (task )
28
26
29
- def stop (self ):
30
- logger .warn ('CronThread stopping...' )
31
- self .loop .call_soon_threadsafe (self .loop .stop )
32
-
33
27
34
28
class Plugin :
35
29
interested : List [Type [Event ]]
@@ -105,7 +99,6 @@ def broad_cast(self, event: Event):
105
99
106
100
async def shutdown (self , timeout : int ):
107
101
logger .info (f'Plugins shutting down, timeout = { timeout } s...' )
108
- self ._cron .stop ()
109
102
for plugin in self .plugins :
110
103
await self ._loop .create_task (plugin .on_shutdown ())
111
104
for i in range (timeout ):
You can’t perform that action at this time.
0 commit comments