mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 01:23:53 +08:00
fix: reduce task startup overhead and lazy-load notifications
This commit is contained in:
1 parent
f168efcdae
commit
7603702eca
7 files changed
+277
-8
No files matched your search
@@ -159,9 +159,13 @@ try {
|
||||
|
||||
run();
|
||||
|
||||
const { sendNotify } = require('./__ql_notify__.js');
|
||||
global.QLAPI = {
|
||||
notify: sendNotify,
|
||||
notify(...args) {
|
||||
// Keep notification dependencies out of ordinary script startup.
|
||||
// require caches the module after the first notification.
|
||||
const { sendNotify } = require('./__ql_notify__.js');
|
||||
return sendNotify.apply(this, args);
|
||||
},
|
||||
...client,
|
||||
};
|
||||
} catch (error) {
|
||||
|
||||
@@ -129,10 +129,12 @@ try:
|
||||
|
||||
run()
|
||||
|
||||
from __ql_notify__ import send
|
||||
|
||||
class BaseApi(Client):
|
||||
def notify(self, *args, **kwargs):
|
||||
# Most scripts never send a notification. Python caches this
|
||||
# module after the first call, including its channel dependencies.
|
||||
from __ql_notify__ import send
|
||||
|
||||
return send(*args, **kwargs)
|
||||
|
||||
QLAPI = BaseApi()
|
||||
|
||||
Reference in new issue
Block a user