|
1 |
| -from typing import Optional, Callable |
2 |
| -from psycopg2 import connect, extensions |
| 1 | +from logging import Logger, getLogger |
3 | 2 | from multiprocessing import Process, Pipe
|
4 | 3 | from multiprocessing.connection import Connection
|
5 |
| -import time |
6 |
| -from select import select |
7 |
| -from logging import Logger, getLogger |
| 4 | +from time import sleep, time |
| 5 | +from typing import Optional, Callable |
| 6 | + |
| 7 | +from psycopg2 import connect, extensions |
| 8 | + |
8 | 9 | from .casbin_channel_subscription import (
|
9 | 10 | casbin_channel_subscription,
|
10 | 11 | _ChannelSubscriptionMessage,
|
@@ -115,7 +116,7 @@ def start(self):
|
115 | 116 | message = int(self.parent_conn.recv())
|
116 | 117 | if message == _ChannelSubscriptionMessage.IS_READY:
|
117 | 118 | break
|
118 |
| - time.sleep(1 / 1000) # wait for 1 ms |
| 119 | + sleep(1 / 1000) # wait for 1 ms |
119 | 120 |
|
120 | 121 | def _cleanup_connections_and_processes(self) -> None:
|
121 | 122 | # Clean up potentially existing Connections and Processes
|
@@ -155,9 +156,7 @@ def update(self) -> None:
|
155 | 156 | # Can only receive notifications when not in transaction, set this for easier usage
|
156 | 157 | conn.set_isolation_level(extensions.ISOLATION_LEVEL_AUTOCOMMIT)
|
157 | 158 | curs = conn.cursor()
|
158 |
| - curs.execute( |
159 |
| - f"NOTIFY {self.channel_name},'casbin policy update at {time.time()}'" |
160 |
| - ) |
| 159 | + curs.execute(f"NOTIFY {self.channel_name},'casbin policy update at {time()}'") |
161 | 160 | conn.close()
|
162 | 161 |
|
163 | 162 | def should_reload(self) -> bool:
|
|
0 commit comments