Code reference
API
Internal
UserCodeException
Bases: Exception
Custom Exception for user-defined catched errors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t |
str
|
Traceback returned by the worker. |
required |
Source code in gibbs/hub.py
18 19 20 21 22 23 24 25 26 |
|
WorkerManager
A helper class that takes care of managing workers. Workers' address can be registered as available, and this class will make sure to return address of workers that are available and alive.
A worker is considered as dead if we didn't receive any heartbeat within a given interval.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
heartbeat_interval |
float
|
Interval of time (in seconds) after which we consider a worker to be dead. |
required |
Source code in gibbs/hub.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
reckon(address)
async
Register the given address as available.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
address |
str
|
Address of the worker to register as available. |
required |
Source code in gibbs/hub.py
50 51 52 53 54 55 56 57 58 |
|
get_next_worker()
async
Retrieve the next available and alive worker's address.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Address of the available and alive worker. |
Source code in gibbs/hub.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
RequestManager
A helper class that takes care of storing responses and waiting for the right response.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
resp_buffer_size |
int
|
Maximum size of the response buffer. |
required |
Source code in gibbs/hub.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
pin(req_id)
Pin a request ID. This is a necessary step when sending a request,
so that the request can be awaited until a response is received.
This method should be called for each req_id
before calling wait_for
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
req_id |
str
|
Request unique identifier. |
required |
Source code in gibbs/hub.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
wait_for(req_id)
async
Async method that waits until we received the response corresponding to the given request ID.
The method pin
should be called before waiting with this method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
req_id |
str
|
Request unique identifier. |
required |
Raises:
Type | Description |
---|---|
KeyError
|
Exception raised if the request wasn't registered previously. |
Returns:
Type | Description |
---|---|
Tuple[int, Any]
|
Tuple[int, Any]: Code and content of the received response. |
Source code in gibbs/hub.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
store(req_id, code, response)
Store a response, to be consumed later.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
req_id |
str
|
Request unique identifier. |
required |
code |
int
|
Code of the response. |
required |
response |
Any
|
Content of the response. |
required |
Source code in gibbs/hub.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|