File tree Expand file tree Collapse file tree 1 file changed +1
-25
lines changed
graphdatascience/query_runner/protocol Expand file tree Collapse file tree 1 file changed +1
-25
lines changed Original file line number Diff line number Diff line change 1
1
import logging
2
- import signal
3
2
import typing
4
- from types import FrameType
5
- from typing import Optional
6
3
7
- from tenacity import RetryCallState , retry_base
8
-
9
-
10
- class retry_unless_signal (retry_base ):
11
- """Retries unless one of the given signals is raised."""
12
-
13
- def __init__ (self , signals : list [signal .Signals ]) -> None :
14
- self .signal_received = False
15
-
16
- def receive_signal (sig : int , frame : Optional [FrameType ]) -> None :
17
- logging .debug (f"Received signal { sig } . Interrupting retry." )
18
- self .signal_received = True
19
-
20
- try :
21
- for sig in signals :
22
- signal .signal (sig , receive_signal )
23
- except ValueError as e :
24
- # signal.signal() can raise ValueError if this is not called in the main thread (such as when an algorithm is called in a ThreadPool)
25
- logging .debug (f"Cannot set signal handler for retries { e } " )
26
-
27
- def __call__ (self , retry_state : RetryCallState ) -> bool :
28
- return not self .signal_received
4
+ from tenacity import RetryCallState
29
5
30
6
31
7
def before_log (
You can’t perform that action at this time.
0 commit comments