isolate 0.13.5__py3-none-any.whl → 0.13.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of isolate might be problematic. Click here for more details.
- isolate/_isolate_version.py +2 -2
- isolate/server/definitions/server.proto +25 -1
- isolate/server/definitions/server_pb2.py +14 -4
- isolate/server/definitions/server_pb2.pyi +71 -2
- isolate/server/definitions/server_pb2_grpc.py +88 -0
- isolate/server/server.py +84 -33
- {isolate-0.13.5.dist-info → isolate-0.13.6.dist-info}/METADATA +1 -1
- {isolate-0.13.5.dist-info → isolate-0.13.6.dist-info}/RECORD +12 -12
- {isolate-0.13.5.dist-info → isolate-0.13.6.dist-info}/WHEEL +1 -1
- {isolate-0.13.5.dist-info → isolate-0.13.6.dist-info}/LICENSE +0 -0
- {isolate-0.13.5.dist-info → isolate-0.13.6.dist-info}/entry_points.txt +0 -0
- {isolate-0.13.5.dist-info → isolate-0.13.6.dist-info}/top_level.txt +0 -0
isolate/_isolate_version.py
CHANGED
|
@@ -10,6 +10,12 @@ service Isolate {
|
|
|
10
10
|
|
|
11
11
|
// Submit a function to be run without waiting for results.
|
|
12
12
|
rpc Submit (SubmitRequest) returns (SubmitResponse) {}
|
|
13
|
+
|
|
14
|
+
// List running tasks
|
|
15
|
+
rpc List (ListRequest) returns (ListResponse) {}
|
|
16
|
+
|
|
17
|
+
// Cancel a running task
|
|
18
|
+
rpc Cancel (CancelRequest) returns (CancelResponse) {}
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
message BoundFunction {
|
|
@@ -33,5 +39,23 @@ message SubmitRequest {
|
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
message SubmitResponse {
|
|
36
|
-
|
|
42
|
+
string task_id = 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
message ListRequest {
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
message TaskInfo {
|
|
49
|
+
string task_id = 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
message ListResponse {
|
|
53
|
+
repeated TaskInfo tasks = 1;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
message CancelRequest {
|
|
57
|
+
string task_id = 1;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
message CancelResponse {
|
|
37
61
|
}
|
|
@@ -16,7 +16,7 @@ from isolate.connections.grpc.definitions import common_pb2 as common__pb2
|
|
|
16
16
|
from google.protobuf import struct_pb2 as google_dot_protobuf_dot_struct__pb2
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0cserver.proto\x1a\x0c\x63ommon.proto\x1a\x1cgoogle/protobuf/struct.proto\"\x9d\x01\n\rBoundFunction\x12,\n\x0c\x65nvironments\x18\x01 \x03(\x0b\x32\x16.EnvironmentDefinition\x12#\n\x08\x66unction\x18\x02 \x01(\x0b\x32\x11.SerializedObject\x12*\n\nsetup_func\x18\x03 \x01(\x0b\x32\x11.SerializedObjectH\x00\x88\x01\x01\x42\r\n\x0b_setup_func\"d\n\x15\x45nvironmentDefinition\x12\x0c\n\x04kind\x18\x01 \x01(\t\x12.\n\rconfiguration\x18\x02 \x01(\x0b\x32\x17.google.protobuf.Struct\x12\r\n\x05\x66orce\x18\x03 \x01(\x08\"1\n\rSubmitRequest\x12 \n\x08\x66unction\x18\x01 \x01(\x0b\x32\x0e.BoundFunction\"\x10\n\
|
|
19
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0cserver.proto\x1a\x0c\x63ommon.proto\x1a\x1cgoogle/protobuf/struct.proto\"\x9d\x01\n\rBoundFunction\x12,\n\x0c\x65nvironments\x18\x01 \x03(\x0b\x32\x16.EnvironmentDefinition\x12#\n\x08\x66unction\x18\x02 \x01(\x0b\x32\x11.SerializedObject\x12*\n\nsetup_func\x18\x03 \x01(\x0b\x32\x11.SerializedObjectH\x00\x88\x01\x01\x42\r\n\x0b_setup_func\"d\n\x15\x45nvironmentDefinition\x12\x0c\n\x04kind\x18\x01 \x01(\t\x12.\n\rconfiguration\x18\x02 \x01(\x0b\x32\x17.google.protobuf.Struct\x12\r\n\x05\x66orce\x18\x03 \x01(\x08\"1\n\rSubmitRequest\x12 \n\x08\x66unction\x18\x01 \x01(\x0b\x32\x0e.BoundFunction\"!\n\x0eSubmitResponse\x12\x0f\n\x07task_id\x18\x01 \x01(\t\"\r\n\x0bListRequest\"\x1b\n\x08TaskInfo\x12\x0f\n\x07task_id\x18\x01 \x01(\t\"(\n\x0cListResponse\x12\x18\n\x05tasks\x18\x01 \x03(\x0b\x32\t.TaskInfo\" \n\rCancelRequest\x12\x0f\n\x07task_id\x18\x01 \x01(\t\"\x10\n\x0e\x43\x61ncelResponse2\xb8\x01\n\x07Isolate\x12,\n\x03Run\x12\x0e.BoundFunction\x1a\x11.PartialRunResult\"\x00\x30\x01\x12+\n\x06Submit\x12\x0e.SubmitRequest\x1a\x0f.SubmitResponse\"\x00\x12%\n\x04List\x12\x0c.ListRequest\x1a\r.ListResponse\"\x00\x12+\n\x06\x43\x61ncel\x12\x0e.CancelRequest\x1a\x0f.CancelResponse\"\x00\x62\x06proto3')
|
|
20
20
|
|
|
21
21
|
_globals = globals()
|
|
22
22
|
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
@@ -30,7 +30,17 @@ if not _descriptor._USE_C_DESCRIPTORS:
|
|
|
30
30
|
_globals['_SUBMITREQUEST']._serialized_start=322
|
|
31
31
|
_globals['_SUBMITREQUEST']._serialized_end=371
|
|
32
32
|
_globals['_SUBMITRESPONSE']._serialized_start=373
|
|
33
|
-
_globals['_SUBMITRESPONSE']._serialized_end=
|
|
34
|
-
_globals['
|
|
35
|
-
_globals['
|
|
33
|
+
_globals['_SUBMITRESPONSE']._serialized_end=406
|
|
34
|
+
_globals['_LISTREQUEST']._serialized_start=408
|
|
35
|
+
_globals['_LISTREQUEST']._serialized_end=421
|
|
36
|
+
_globals['_TASKINFO']._serialized_start=423
|
|
37
|
+
_globals['_TASKINFO']._serialized_end=450
|
|
38
|
+
_globals['_LISTRESPONSE']._serialized_start=452
|
|
39
|
+
_globals['_LISTRESPONSE']._serialized_end=492
|
|
40
|
+
_globals['_CANCELREQUEST']._serialized_start=494
|
|
41
|
+
_globals['_CANCELREQUEST']._serialized_end=526
|
|
42
|
+
_globals['_CANCELRESPONSE']._serialized_start=528
|
|
43
|
+
_globals['_CANCELRESPONSE']._serialized_end=544
|
|
44
|
+
_globals['_ISOLATE']._serialized_start=547
|
|
45
|
+
_globals['_ISOLATE']._serialized_end=731
|
|
36
46
|
# @@protoc_insertion_point(module_scope)
|
|
@@ -88,12 +88,81 @@ global___SubmitRequest = SubmitRequest
|
|
|
88
88
|
|
|
89
89
|
@typing.final
|
|
90
90
|
class SubmitResponse(google.protobuf.message.Message):
|
|
91
|
-
"""Reserved for future use."""
|
|
92
|
-
|
|
93
91
|
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
|
94
92
|
|
|
93
|
+
TASK_ID_FIELD_NUMBER: builtins.int
|
|
94
|
+
task_id: builtins.str
|
|
95
95
|
def __init__(
|
|
96
96
|
self,
|
|
97
|
+
*,
|
|
98
|
+
task_id: builtins.str = ...,
|
|
97
99
|
) -> None: ...
|
|
100
|
+
def ClearField(self, field_name: typing.Literal["task_id", b"task_id"]) -> None: ...
|
|
98
101
|
|
|
99
102
|
global___SubmitResponse = SubmitResponse
|
|
103
|
+
|
|
104
|
+
@typing.final
|
|
105
|
+
class ListRequest(google.protobuf.message.Message):
|
|
106
|
+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
|
107
|
+
|
|
108
|
+
def __init__(
|
|
109
|
+
self,
|
|
110
|
+
) -> None: ...
|
|
111
|
+
|
|
112
|
+
global___ListRequest = ListRequest
|
|
113
|
+
|
|
114
|
+
@typing.final
|
|
115
|
+
class TaskInfo(google.protobuf.message.Message):
|
|
116
|
+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
|
117
|
+
|
|
118
|
+
TASK_ID_FIELD_NUMBER: builtins.int
|
|
119
|
+
task_id: builtins.str
|
|
120
|
+
def __init__(
|
|
121
|
+
self,
|
|
122
|
+
*,
|
|
123
|
+
task_id: builtins.str = ...,
|
|
124
|
+
) -> None: ...
|
|
125
|
+
def ClearField(self, field_name: typing.Literal["task_id", b"task_id"]) -> None: ...
|
|
126
|
+
|
|
127
|
+
global___TaskInfo = TaskInfo
|
|
128
|
+
|
|
129
|
+
@typing.final
|
|
130
|
+
class ListResponse(google.protobuf.message.Message):
|
|
131
|
+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
|
132
|
+
|
|
133
|
+
TASKS_FIELD_NUMBER: builtins.int
|
|
134
|
+
@property
|
|
135
|
+
def tasks(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___TaskInfo]: ...
|
|
136
|
+
def __init__(
|
|
137
|
+
self,
|
|
138
|
+
*,
|
|
139
|
+
tasks: collections.abc.Iterable[global___TaskInfo] | None = ...,
|
|
140
|
+
) -> None: ...
|
|
141
|
+
def ClearField(self, field_name: typing.Literal["tasks", b"tasks"]) -> None: ...
|
|
142
|
+
|
|
143
|
+
global___ListResponse = ListResponse
|
|
144
|
+
|
|
145
|
+
@typing.final
|
|
146
|
+
class CancelRequest(google.protobuf.message.Message):
|
|
147
|
+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
|
148
|
+
|
|
149
|
+
TASK_ID_FIELD_NUMBER: builtins.int
|
|
150
|
+
task_id: builtins.str
|
|
151
|
+
def __init__(
|
|
152
|
+
self,
|
|
153
|
+
*,
|
|
154
|
+
task_id: builtins.str = ...,
|
|
155
|
+
) -> None: ...
|
|
156
|
+
def ClearField(self, field_name: typing.Literal["task_id", b"task_id"]) -> None: ...
|
|
157
|
+
|
|
158
|
+
global___CancelRequest = CancelRequest
|
|
159
|
+
|
|
160
|
+
@typing.final
|
|
161
|
+
class CancelResponse(google.protobuf.message.Message):
|
|
162
|
+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
|
163
|
+
|
|
164
|
+
def __init__(
|
|
165
|
+
self,
|
|
166
|
+
) -> None: ...
|
|
167
|
+
|
|
168
|
+
global___CancelResponse = CancelResponse
|
|
@@ -50,6 +50,16 @@ class IsolateStub(object):
|
|
|
50
50
|
request_serializer=server__pb2.SubmitRequest.SerializeToString,
|
|
51
51
|
response_deserializer=server__pb2.SubmitResponse.FromString,
|
|
52
52
|
_registered_method=True)
|
|
53
|
+
self.List = channel.unary_unary(
|
|
54
|
+
'/Isolate/List',
|
|
55
|
+
request_serializer=server__pb2.ListRequest.SerializeToString,
|
|
56
|
+
response_deserializer=server__pb2.ListResponse.FromString,
|
|
57
|
+
_registered_method=True)
|
|
58
|
+
self.Cancel = channel.unary_unary(
|
|
59
|
+
'/Isolate/Cancel',
|
|
60
|
+
request_serializer=server__pb2.CancelRequest.SerializeToString,
|
|
61
|
+
response_deserializer=server__pb2.CancelResponse.FromString,
|
|
62
|
+
_registered_method=True)
|
|
53
63
|
|
|
54
64
|
|
|
55
65
|
class IsolateServicer(object):
|
|
@@ -70,6 +80,20 @@ class IsolateServicer(object):
|
|
|
70
80
|
context.set_details('Method not implemented!')
|
|
71
81
|
raise NotImplementedError('Method not implemented!')
|
|
72
82
|
|
|
83
|
+
def List(self, request, context):
|
|
84
|
+
"""List running tasks
|
|
85
|
+
"""
|
|
86
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
87
|
+
context.set_details('Method not implemented!')
|
|
88
|
+
raise NotImplementedError('Method not implemented!')
|
|
89
|
+
|
|
90
|
+
def Cancel(self, request, context):
|
|
91
|
+
"""Cancel a running task
|
|
92
|
+
"""
|
|
93
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
94
|
+
context.set_details('Method not implemented!')
|
|
95
|
+
raise NotImplementedError('Method not implemented!')
|
|
96
|
+
|
|
73
97
|
|
|
74
98
|
def add_IsolateServicer_to_server(servicer, server):
|
|
75
99
|
rpc_method_handlers = {
|
|
@@ -83,6 +107,16 @@ def add_IsolateServicer_to_server(servicer, server):
|
|
|
83
107
|
request_deserializer=server__pb2.SubmitRequest.FromString,
|
|
84
108
|
response_serializer=server__pb2.SubmitResponse.SerializeToString,
|
|
85
109
|
),
|
|
110
|
+
'List': grpc.unary_unary_rpc_method_handler(
|
|
111
|
+
servicer.List,
|
|
112
|
+
request_deserializer=server__pb2.ListRequest.FromString,
|
|
113
|
+
response_serializer=server__pb2.ListResponse.SerializeToString,
|
|
114
|
+
),
|
|
115
|
+
'Cancel': grpc.unary_unary_rpc_method_handler(
|
|
116
|
+
servicer.Cancel,
|
|
117
|
+
request_deserializer=server__pb2.CancelRequest.FromString,
|
|
118
|
+
response_serializer=server__pb2.CancelResponse.SerializeToString,
|
|
119
|
+
),
|
|
86
120
|
}
|
|
87
121
|
generic_handler = grpc.method_handlers_generic_handler(
|
|
88
122
|
'Isolate', rpc_method_handlers)
|
|
@@ -147,3 +181,57 @@ class Isolate(object):
|
|
|
147
181
|
timeout,
|
|
148
182
|
metadata,
|
|
149
183
|
_registered_method=True)
|
|
184
|
+
|
|
185
|
+
@staticmethod
|
|
186
|
+
def List(request,
|
|
187
|
+
target,
|
|
188
|
+
options=(),
|
|
189
|
+
channel_credentials=None,
|
|
190
|
+
call_credentials=None,
|
|
191
|
+
insecure=False,
|
|
192
|
+
compression=None,
|
|
193
|
+
wait_for_ready=None,
|
|
194
|
+
timeout=None,
|
|
195
|
+
metadata=None):
|
|
196
|
+
return grpc.experimental.unary_unary(
|
|
197
|
+
request,
|
|
198
|
+
target,
|
|
199
|
+
'/Isolate/List',
|
|
200
|
+
server__pb2.ListRequest.SerializeToString,
|
|
201
|
+
server__pb2.ListResponse.FromString,
|
|
202
|
+
options,
|
|
203
|
+
channel_credentials,
|
|
204
|
+
insecure,
|
|
205
|
+
call_credentials,
|
|
206
|
+
compression,
|
|
207
|
+
wait_for_ready,
|
|
208
|
+
timeout,
|
|
209
|
+
metadata,
|
|
210
|
+
_registered_method=True)
|
|
211
|
+
|
|
212
|
+
@staticmethod
|
|
213
|
+
def Cancel(request,
|
|
214
|
+
target,
|
|
215
|
+
options=(),
|
|
216
|
+
channel_credentials=None,
|
|
217
|
+
call_credentials=None,
|
|
218
|
+
insecure=False,
|
|
219
|
+
compression=None,
|
|
220
|
+
wait_for_ready=None,
|
|
221
|
+
timeout=None,
|
|
222
|
+
metadata=None):
|
|
223
|
+
return grpc.experimental.unary_unary(
|
|
224
|
+
request,
|
|
225
|
+
target,
|
|
226
|
+
'/Isolate/Cancel',
|
|
227
|
+
server__pb2.CancelRequest.SerializeToString,
|
|
228
|
+
server__pb2.CancelResponse.FromString,
|
|
229
|
+
options,
|
|
230
|
+
channel_credentials,
|
|
231
|
+
insecure,
|
|
232
|
+
call_credentials,
|
|
233
|
+
compression,
|
|
234
|
+
wait_for_ready,
|
|
235
|
+
timeout,
|
|
236
|
+
metadata,
|
|
237
|
+
_registered_method=True)
|
isolate/server/server.py
CHANGED
|
@@ -4,6 +4,7 @@ import os
|
|
|
4
4
|
import threading
|
|
5
5
|
import time
|
|
6
6
|
import traceback
|
|
7
|
+
import uuid
|
|
7
8
|
from collections import defaultdict
|
|
8
9
|
from concurrent import futures
|
|
9
10
|
from concurrent.futures import ThreadPoolExecutor
|
|
@@ -114,11 +115,11 @@ class BridgeManager:
|
|
|
114
115
|
self,
|
|
115
116
|
connection: LocalPythonGRPC,
|
|
116
117
|
queue: Queue,
|
|
117
|
-
) -> Iterator[
|
|
118
|
+
) -> Iterator[RunnerAgent]:
|
|
118
119
|
agent = self._allocate_new_agent(connection, queue)
|
|
119
120
|
|
|
120
121
|
try:
|
|
121
|
-
yield agent
|
|
122
|
+
yield agent
|
|
122
123
|
finally:
|
|
123
124
|
self._cache_agent(connection, agent)
|
|
124
125
|
|
|
@@ -165,19 +166,34 @@ class BridgeManager:
|
|
|
165
166
|
agent.terminate()
|
|
166
167
|
|
|
167
168
|
|
|
169
|
+
@dataclass
|
|
170
|
+
class RunTask:
|
|
171
|
+
request: definitions.BoundFunction
|
|
172
|
+
future: futures.Future | None = None
|
|
173
|
+
agent: RunnerAgent | None = None
|
|
174
|
+
|
|
175
|
+
def cancel(self):
|
|
176
|
+
while True:
|
|
177
|
+
self.future.cancel()
|
|
178
|
+
if self.agent:
|
|
179
|
+
self.agent.terminate()
|
|
180
|
+
try:
|
|
181
|
+
self.future.exception(timeout=0.1)
|
|
182
|
+
return
|
|
183
|
+
except futures.TimeoutError:
|
|
184
|
+
pass
|
|
185
|
+
|
|
186
|
+
|
|
168
187
|
@dataclass
|
|
169
188
|
class IsolateServicer(definitions.IsolateServicer):
|
|
170
189
|
bridge_manager: BridgeManager
|
|
171
190
|
default_settings: IsolateSettings = field(default_factory=IsolateSettings)
|
|
172
|
-
background_tasks:
|
|
191
|
+
background_tasks: dict[str, RunTask] = field(default_factory=dict)
|
|
173
192
|
|
|
174
|
-
def
|
|
175
|
-
self,
|
|
176
|
-
request: definitions.BoundFunction,
|
|
177
|
-
) -> Iterator[definitions.PartialRunResult]:
|
|
193
|
+
def _run_task(self, task: RunTask) -> Iterator[definitions.PartialRunResult]:
|
|
178
194
|
messages: Queue[definitions.PartialRunResult] = Queue()
|
|
179
195
|
environments = []
|
|
180
|
-
for env in request.environments:
|
|
196
|
+
for env in task.request.environments:
|
|
181
197
|
try:
|
|
182
198
|
environments.append((env.force, from_grpc(env)))
|
|
183
199
|
except ValueError:
|
|
@@ -195,7 +211,7 @@ class IsolateServicer(definitions.IsolateServicer):
|
|
|
195
211
|
run_settings = replace(
|
|
196
212
|
self.default_settings,
|
|
197
213
|
log_hook=log_handler.handle,
|
|
198
|
-
serialization_method=request.function.method,
|
|
214
|
+
serialization_method=task.request.function.method,
|
|
199
215
|
)
|
|
200
216
|
|
|
201
217
|
for _, environment in environments:
|
|
@@ -244,28 +260,28 @@ class IsolateServicer(definitions.IsolateServicer):
|
|
|
244
260
|
extra_inheritance_paths=inheritance_paths,
|
|
245
261
|
)
|
|
246
262
|
|
|
247
|
-
with self.bridge_manager.establish(connection, queue=messages) as
|
|
248
|
-
|
|
249
|
-
queue,
|
|
250
|
-
):
|
|
263
|
+
with self.bridge_manager.establish(connection, queue=messages) as agent:
|
|
264
|
+
task.agent = agent
|
|
251
265
|
function_call = definitions.FunctionCall(
|
|
252
|
-
function=request.function,
|
|
253
|
-
setup_func=request.setup_func,
|
|
266
|
+
function=task.request.function,
|
|
267
|
+
setup_func=task.request.setup_func,
|
|
254
268
|
)
|
|
255
|
-
if not request.HasField("setup_func"):
|
|
269
|
+
if not task.request.HasField("setup_func"):
|
|
256
270
|
function_call.ClearField("setup_func")
|
|
257
271
|
|
|
258
272
|
future = local_pool.submit(
|
|
259
273
|
_proxy_to_queue,
|
|
260
|
-
queue=
|
|
261
|
-
bridge=
|
|
274
|
+
queue=agent.message_queue,
|
|
275
|
+
bridge=agent.stub,
|
|
262
276
|
input=function_call,
|
|
263
277
|
)
|
|
264
278
|
|
|
265
279
|
# Unlike above; we are not interested in the result value of future
|
|
266
280
|
# here, since it will be already transferred to other side without
|
|
267
281
|
# us even seeing (through the queue).
|
|
268
|
-
yield from self.watch_queue_until_completed(
|
|
282
|
+
yield from self.watch_queue_until_completed(
|
|
283
|
+
agent.message_queue, future.done
|
|
284
|
+
)
|
|
269
285
|
|
|
270
286
|
# But we still have to check whether there were any errors raised
|
|
271
287
|
# during the execution, and handle them accordingly.
|
|
@@ -293,14 +309,8 @@ class IsolateServicer(definitions.IsolateServicer):
|
|
|
293
309
|
StatusCode.UNKNOWN,
|
|
294
310
|
)
|
|
295
311
|
|
|
296
|
-
def
|
|
297
|
-
self
|
|
298
|
-
bound_function: definitions.BoundFunction,
|
|
299
|
-
) -> None:
|
|
300
|
-
try:
|
|
301
|
-
for _ in self._run_function(bound_function):
|
|
302
|
-
pass
|
|
303
|
-
except GRPCException:
|
|
312
|
+
def _run_task_in_background(self, task: RunTask) -> None:
|
|
313
|
+
for _ in self._run_task(task):
|
|
304
314
|
pass
|
|
305
315
|
|
|
306
316
|
def Submit(
|
|
@@ -308,13 +318,24 @@ class IsolateServicer(definitions.IsolateServicer):
|
|
|
308
318
|
request: definitions.SubmitRequest,
|
|
309
319
|
context: ServicerContext,
|
|
310
320
|
) -> definitions.SubmitResponse:
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
321
|
+
task = RunTask(request=request.function)
|
|
322
|
+
task.future = RUNNER_THREAD_POOL.submit(
|
|
323
|
+
self._run_task_in_background,
|
|
324
|
+
task,
|
|
314
325
|
)
|
|
315
|
-
|
|
326
|
+
task_id = str(uuid.uuid4())
|
|
327
|
+
|
|
328
|
+
print(f"Submitted a task {task_id}")
|
|
316
329
|
|
|
317
|
-
|
|
330
|
+
self.background_tasks[task_id] = task
|
|
331
|
+
|
|
332
|
+
def _callback(_):
|
|
333
|
+
print(f"Task {task_id} finished")
|
|
334
|
+
self.background_tasks.pop(task_id, None)
|
|
335
|
+
|
|
336
|
+
task.future.add_done_callback(_callback)
|
|
337
|
+
|
|
338
|
+
return definitions.SubmitResponse(task_id=task_id)
|
|
318
339
|
|
|
319
340
|
def Run(
|
|
320
341
|
self,
|
|
@@ -322,7 +343,7 @@ class IsolateServicer(definitions.IsolateServicer):
|
|
|
322
343
|
context: ServicerContext,
|
|
323
344
|
) -> Iterator[definitions.PartialRunResult]:
|
|
324
345
|
try:
|
|
325
|
-
yield from self.
|
|
346
|
+
yield from self._run_task(RunTask(request=request))
|
|
326
347
|
except GRPCException as exc:
|
|
327
348
|
return self.abort_with_msg(
|
|
328
349
|
exc.message,
|
|
@@ -330,6 +351,32 @@ class IsolateServicer(definitions.IsolateServicer):
|
|
|
330
351
|
code=exc.code,
|
|
331
352
|
)
|
|
332
353
|
|
|
354
|
+
def List(
|
|
355
|
+
self,
|
|
356
|
+
request: definitions.ListRequest,
|
|
357
|
+
context: ServicerContext,
|
|
358
|
+
) -> definitions.ListResponse:
|
|
359
|
+
return definitions.ListResponse(
|
|
360
|
+
tasks=[
|
|
361
|
+
definitions.TaskInfo(task_id=task_id)
|
|
362
|
+
for task_id in self.background_tasks.keys()
|
|
363
|
+
]
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
def Cancel(
|
|
367
|
+
self,
|
|
368
|
+
request: definitions.CancelRequest,
|
|
369
|
+
context: ServicerContext,
|
|
370
|
+
) -> definitions.CancelResponse:
|
|
371
|
+
task_id = request.task_id
|
|
372
|
+
|
|
373
|
+
print(f"Canceling task {task_id}")
|
|
374
|
+
task = self.background_tasks.get(task_id)
|
|
375
|
+
if task is not None:
|
|
376
|
+
task.cancel()
|
|
377
|
+
|
|
378
|
+
return definitions.CancelResponse()
|
|
379
|
+
|
|
333
380
|
def watch_queue_until_completed(
|
|
334
381
|
self, queue: Queue, is_completed: Callable[[], bool]
|
|
335
382
|
) -> Iterator[definitions.PartialRunResult]:
|
|
@@ -381,6 +428,10 @@ class IsolateServicer(definitions.IsolateServicer):
|
|
|
381
428
|
context.set_details(message)
|
|
382
429
|
return None
|
|
383
430
|
|
|
431
|
+
def cancel_tasks(self):
|
|
432
|
+
for task in self.background_tasks.values():
|
|
433
|
+
task.cancel()
|
|
434
|
+
|
|
384
435
|
|
|
385
436
|
def _proxy_to_queue(
|
|
386
437
|
queue: Queue,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
isolate/__init__.py,sha256=uXOKnONs7sXgARNgElwr4_A1sKoA6ACHVEvs3IDiX1M,127
|
|
2
|
-
isolate/_isolate_version.py,sha256=
|
|
2
|
+
isolate/_isolate_version.py,sha256=zzSYUoANo8Flx9JbASsXdKUFyreIjmnWWP8bU7b8Jvk,413
|
|
3
3
|
isolate/_version.py,sha256=05pXvy-yr5t3I1m9JMn42Ilzpg7fa8IB2J8a3G7t1cU,274
|
|
4
4
|
isolate/logger.py,sha256=SehnK6rPx-HDqQHJ3sKWqhDGmD3fTDGBIkjnNQYnFJU,453
|
|
5
5
|
isolate/logs.py,sha256=R_AHUVYD18z_PhtK_mDWi9Gch79CxmwHY09hUDShtwg,2079
|
|
@@ -42,20 +42,20 @@ isolate/connections/ipc/agent.py,sha256=hGlL4x78FhRvMZ4DkVh3dk-EmWQqxHW4LIipgyOk
|
|
|
42
42
|
isolate/server/__init__.py,sha256=7R3GuWmxuqe0q28rVqETJN9OCrP_-Svjv9h0NR1GFL0,79
|
|
43
43
|
isolate/server/health_server.py,sha256=yN7F1Q28DdX8-Zk3gef7XcQEE25XwlHwzV5GBM75aQM,1249
|
|
44
44
|
isolate/server/interface.py,sha256=nGbjdxrN0p9m1LNdeds8NIoJOwPYW2NM6ktmbhfG4_s,687
|
|
45
|
-
isolate/server/server.py,sha256=
|
|
45
|
+
isolate/server/server.py,sha256=2bn5r9L1OvqtaIfCMmq0J8hwYaxI0VE7aGHGA7ShZ6o,16314
|
|
46
46
|
isolate/server/definitions/__init__.py,sha256=f_Q3pdjMuZrjgNlbM60btFKiB1Vg8cnVyKEbp0RmU0A,572
|
|
47
|
-
isolate/server/definitions/server.proto,sha256
|
|
48
|
-
isolate/server/definitions/server_pb2.py,sha256=
|
|
49
|
-
isolate/server/definitions/server_pb2.pyi,sha256=
|
|
50
|
-
isolate/server/definitions/server_pb2_grpc.py,sha256=
|
|
47
|
+
isolate/server/definitions/server.proto,sha256=GIou0c_RP4sVDxjdYQzUtSptOfJtvbgsU4MGhL9hsMQ,1372
|
|
48
|
+
isolate/server/definitions/server_pb2.py,sha256=SdbigRwRd1pU1yFwvyrA4vkmwQHPelPkQT7dtggKUlk,3194
|
|
49
|
+
isolate/server/definitions/server_pb2.pyi,sha256=kEo781qnfiYpR9ok7CDdn4kaqdkEgB_66wT4qLMk3M4,5594
|
|
50
|
+
isolate/server/definitions/server_pb2_grpc.py,sha256=lSGH6BeQf9cbdESlteNfMlDkFXIFjeVR7PVo-b0k3HM,8455
|
|
51
51
|
isolate/server/health/__init__.py,sha256=sy349GRK2YGX9KFKqDxM-jdYtBpMXjZu1QwBkjn0SsM,337
|
|
52
52
|
isolate/server/health/health.proto,sha256=wE2_QD0OQAblKkEBG7sALLXEOj1mOLKG-FbC4tFopWE,455
|
|
53
53
|
isolate/server/health/health_pb2.py,sha256=onOdP3M4Tpqhqs2PlGcyfoKe2VVKUEDx5ALeRcObb9A,1899
|
|
54
54
|
isolate/server/health/health_pb2.pyi,sha256=CPyvxvDzra-1d-mBsukaJnscMUDBaqSACvo9LiXlFzo,2416
|
|
55
55
|
isolate/server/health/health_pb2_grpc.py,sha256=XgsULrnRBmYIqvKr8eI7bqs6NIea5A0kkqdOOc2JHBY,5303
|
|
56
|
-
isolate-0.13.
|
|
57
|
-
isolate-0.13.
|
|
58
|
-
isolate-0.13.
|
|
59
|
-
isolate-0.13.
|
|
60
|
-
isolate-0.13.
|
|
61
|
-
isolate-0.13.
|
|
56
|
+
isolate-0.13.6.dist-info/LICENSE,sha256=427vuyirL5scgBLqA9UWcdnxKrtSGc0u_JfUupk6lAA,11359
|
|
57
|
+
isolate-0.13.6.dist-info/METADATA,sha256=0O9_trMdTSoH5Pr1f4qVYrZarO_iHPRwoWwnBcoK3Ks,3209
|
|
58
|
+
isolate-0.13.6.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
|
|
59
|
+
isolate-0.13.6.dist-info/entry_points.txt,sha256=s3prh2EERaVCbL8R45tfY5WFPZ1TsYOsz305YR7s-Pc,360
|
|
60
|
+
isolate-0.13.6.dist-info/top_level.txt,sha256=W9QJBHcq5WXRkbOXf25bvftzFsOZZN4n1DAatdroZrs,8
|
|
61
|
+
isolate-0.13.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|