robotcode-jsonrpc2 0.64.1__tar.gz → 0.66.0__tar.gz
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.
- {robotcode_jsonrpc2-0.64.1 → robotcode_jsonrpc2-0.66.0}/PKG-INFO +2 -2
- {robotcode_jsonrpc2-0.64.1 → robotcode_jsonrpc2-0.66.0}/pyproject.toml +1 -1
- robotcode_jsonrpc2-0.66.0/src/robotcode/jsonrpc2/__version__.py +1 -0
- {robotcode_jsonrpc2-0.64.1 → robotcode_jsonrpc2-0.66.0}/src/robotcode/jsonrpc2/protocol.py +19 -80
- robotcode_jsonrpc2-0.64.1/src/robotcode/jsonrpc2/__version__.py +0 -1
- {robotcode_jsonrpc2-0.64.1 → robotcode_jsonrpc2-0.66.0}/.gitignore +0 -0
- {robotcode_jsonrpc2-0.64.1 → robotcode_jsonrpc2-0.66.0}/LICENSE.txt +0 -0
- {robotcode_jsonrpc2-0.64.1 → robotcode_jsonrpc2-0.66.0}/README.md +0 -0
- {robotcode_jsonrpc2-0.64.1 → robotcode_jsonrpc2-0.66.0}/src/robotcode/jsonrpc2/__init__.py +0 -0
- {robotcode_jsonrpc2-0.64.1 → robotcode_jsonrpc2-0.66.0}/src/robotcode/jsonrpc2/py.typed +0 -0
- {robotcode_jsonrpc2-0.64.1 → robotcode_jsonrpc2-0.66.0}/src/robotcode/jsonrpc2/server.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: robotcode-jsonrpc2
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.66.0
|
|
4
4
|
Summary: JSONRPC Server for RobotCode
|
|
5
5
|
Project-URL: Homepage, https://robotcode.io
|
|
6
6
|
Project-URL: Donate, https://github.com/sponsors/d-biehl
|
|
@@ -25,7 +25,7 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
|
25
25
|
Classifier: Topic :: Utilities
|
|
26
26
|
Classifier: Typing :: Typed
|
|
27
27
|
Requires-Python: >=3.8
|
|
28
|
-
Requires-Dist: robotcode-core==0.
|
|
28
|
+
Requires-Dist: robotcode-core==0.66.0
|
|
29
29
|
Description-Content-Type: text/markdown
|
|
30
30
|
|
|
31
31
|
# robotcode-jsonrpc2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.66.0"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
|
+
import concurrent.futures
|
|
4
5
|
import inspect
|
|
5
6
|
import json
|
|
6
7
|
import re
|
|
7
8
|
import threading
|
|
8
|
-
import time
|
|
9
9
|
import weakref
|
|
10
10
|
from abc import ABC, abstractmethod
|
|
11
11
|
from collections import OrderedDict
|
|
@@ -36,7 +36,6 @@ from typing import (
|
|
|
36
36
|
from robotcode.core.async_tools import (
|
|
37
37
|
HasThreaded,
|
|
38
38
|
async_event,
|
|
39
|
-
create_sub_future,
|
|
40
39
|
create_sub_task,
|
|
41
40
|
run_coroutine_in_thread,
|
|
42
41
|
)
|
|
@@ -336,7 +335,7 @@ class RpcRegistry:
|
|
|
336
335
|
|
|
337
336
|
|
|
338
337
|
class SendedRequestEntry(NamedTuple):
|
|
339
|
-
future:
|
|
338
|
+
future: concurrent.futures.Future[Any]
|
|
340
339
|
result_type: Optional[Type[Any]]
|
|
341
340
|
|
|
342
341
|
|
|
@@ -546,9 +545,9 @@ class JsonRPCProtocol(JsonRPCProtocolBase):
|
|
|
546
545
|
method: str,
|
|
547
546
|
params: Optional[Any] = None,
|
|
548
547
|
return_type_or_converter: Optional[Type[_TResult]] = None,
|
|
549
|
-
) ->
|
|
548
|
+
) -> concurrent.futures.Future[_TResult]:
|
|
550
549
|
with self._sended_request_lock:
|
|
551
|
-
result:
|
|
550
|
+
result: concurrent.futures.Future[_TResult] = concurrent.futures.Future()
|
|
552
551
|
self._sended_request_count += 1
|
|
553
552
|
id = self._sended_request_count
|
|
554
553
|
|
|
@@ -559,13 +558,13 @@ class JsonRPCProtocol(JsonRPCProtocolBase):
|
|
|
559
558
|
|
|
560
559
|
return result
|
|
561
560
|
|
|
562
|
-
|
|
561
|
+
def send_request_async(
|
|
563
562
|
self,
|
|
564
563
|
method: str,
|
|
565
564
|
params: Optional[Any] = None,
|
|
566
565
|
return_type: Optional[Type[_TResult]] = None,
|
|
567
|
-
) ->
|
|
568
|
-
return
|
|
566
|
+
) -> asyncio.Future[_TResult]:
|
|
567
|
+
return asyncio.wrap_future(self.send_request(method, params, return_type))
|
|
569
568
|
|
|
570
569
|
@__logger.call
|
|
571
570
|
def send_notification(self, method: str, params: Any) -> None:
|
|
@@ -590,44 +589,17 @@ class JsonRPCProtocol(JsonRPCProtocolBase):
|
|
|
590
589
|
|
|
591
590
|
try:
|
|
592
591
|
if not entry.future.done():
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
else:
|
|
599
|
-
if entry.future.get_loop().is_running():
|
|
600
|
-
|
|
601
|
-
def set_result(f: asyncio.Future[Any], r: Any, ev: threading.Event) -> None:
|
|
602
|
-
try:
|
|
603
|
-
if not f.done() and f.get_loop().is_running():
|
|
604
|
-
f.set_result(r)
|
|
605
|
-
finally:
|
|
606
|
-
ev.set()
|
|
607
|
-
|
|
608
|
-
done = threading.Event()
|
|
609
|
-
|
|
610
|
-
entry.future.get_loop().call_soon_threadsafe(set_result, entry.future, res, done)
|
|
611
|
-
|
|
612
|
-
start = time.monotonic()
|
|
613
|
-
while not done.is_set():
|
|
614
|
-
if time.monotonic() - start > 120:
|
|
615
|
-
raise TimeoutError("Can't set future result.")
|
|
616
|
-
|
|
617
|
-
await asyncio.sleep(0)
|
|
618
|
-
|
|
619
|
-
else:
|
|
620
|
-
self.__logger.warning(lambda: f"Response {entry!r} loop is not running.")
|
|
592
|
+
entry.future.set_result(
|
|
593
|
+
from_dict(message.result, entry.result_type) if message.result is not None else None
|
|
594
|
+
)
|
|
595
|
+
else:
|
|
596
|
+
self.__logger.warning(lambda: f"Response for {message} is already done.")
|
|
621
597
|
|
|
622
598
|
except (SystemExit, KeyboardInterrupt):
|
|
623
599
|
raise
|
|
624
600
|
except BaseException as e:
|
|
625
601
|
if not entry.future.done():
|
|
626
|
-
|
|
627
|
-
entry.future.set_exception(e)
|
|
628
|
-
else:
|
|
629
|
-
if entry.future.get_loop().is_running():
|
|
630
|
-
entry.future.get_loop().call_soon_threadsafe(entry.future.set_exception, e)
|
|
602
|
+
entry.future.set_exception(e)
|
|
631
603
|
|
|
632
604
|
@__logger.call
|
|
633
605
|
async def handle_error(self, message: JsonRPCError) -> None:
|
|
@@ -646,50 +618,17 @@ class JsonRPCProtocol(JsonRPCProtocolBase):
|
|
|
646
618
|
|
|
647
619
|
try:
|
|
648
620
|
if not entry.future.done():
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
JsonRPCErrorException(message.error.code, message.error.message, message.error.data)
|
|
655
|
-
)
|
|
656
|
-
else:
|
|
657
|
-
if entry.future.get_loop().is_running():
|
|
658
|
-
|
|
659
|
-
def set_result(f: asyncio.Future[Any], r: Any, ev: threading.Event) -> None:
|
|
660
|
-
try:
|
|
661
|
-
if not f.done() and f.get_loop().is_running():
|
|
662
|
-
f.set_exception(
|
|
663
|
-
JsonRPCErrorException(
|
|
664
|
-
message.error.code, message.error.message, message.error.data
|
|
665
|
-
)
|
|
666
|
-
)
|
|
667
|
-
finally:
|
|
668
|
-
ev.set()
|
|
669
|
-
|
|
670
|
-
done = threading.Event()
|
|
671
|
-
|
|
672
|
-
entry.future.get_loop().call_soon_threadsafe(set_result, entry.future, res, done)
|
|
673
|
-
|
|
674
|
-
start = time.monotonic()
|
|
675
|
-
while not done.is_set():
|
|
676
|
-
if time.monotonic() - start > 120:
|
|
677
|
-
raise TimeoutError("Can't set future result.")
|
|
678
|
-
|
|
679
|
-
await asyncio.sleep(0)
|
|
680
|
-
|
|
681
|
-
else:
|
|
682
|
-
self.__logger.warning(lambda: f"Response {entry!r} loop is not running.")
|
|
621
|
+
entry.future.set_exception(
|
|
622
|
+
JsonRPCErrorException(message.error.code, message.error.message, message.error.data)
|
|
623
|
+
)
|
|
624
|
+
else:
|
|
625
|
+
self.__logger.warning(lambda: f"Response for {message} is already done.")
|
|
683
626
|
|
|
684
627
|
except (SystemExit, KeyboardInterrupt):
|
|
685
628
|
raise
|
|
686
629
|
except BaseException as e:
|
|
687
630
|
if not entry.future.done():
|
|
688
|
-
|
|
689
|
-
entry.future.set_exception(e)
|
|
690
|
-
else:
|
|
691
|
-
if entry.future.get_loop().is_running():
|
|
692
|
-
entry.future.get_loop().call_soon_threadsafe(entry.future.set_exception, e)
|
|
631
|
+
entry.future.set_exception(e)
|
|
693
632
|
|
|
694
633
|
@staticmethod
|
|
695
634
|
def _convert_params(
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.64.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|