FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-sdk/src/acp/task/queue.py at package-scripts · openSUSE-Python/python-sdk · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
openSUSE-Python
/
python-sdk
Public
forked from
agentclientprotocol/python-sdk
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-sdk
/
src
/
acp
/
task
/
queue.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
67 lines (46 loc) · 1.69 KB
Breadcrumbs
python-sdk
/
src
/
acp
/
task
/
queue.py
Copy path
File metadata and controls
67 lines (46 loc) · 1.69 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
from
__future__
import
annotations
import
asyncio
from
collections
.
abc
import
AsyncIterator
from
contextlib
import
suppress
from
typing
import
Protocol
from
.
import
RpcTask
__all__
=
[
"InMemoryMessageQueue"
,
"MessageQueue"
]
class
MessageQueue
(
Protocol
):
async
def
publish
(
self
,
task
:
RpcTask
)
->
None
: ...
async
def
close
(
self
)
->
None
: ...
def
task_done
(
self
)
->
None
: ...
async
def
join
(
self
)
->
None
: ...
def
__aiter__
(
self
)
->
AsyncIterator
[
RpcTask
]: ...
class
InMemoryMessageQueue
:
"""Simple in-memory broker for RPC task dispatch."""
def
__init__
(
self
,
*
,
maxsize
:
int
=
0
)
->
None
:
self
.
_queue
:
asyncio
.
Queue
[
RpcTask
|
None
]
=
asyncio
.
Queue
(
maxsize
=
maxsize
)
self
.
_closed
=
False
async
def
publish
(
self
,
task
:
RpcTask
)
->
None
:
if
self
.
_closed
:
msg
=
"mssage queue already closed"
raise
RuntimeError
(
msg
)
await
self
.
_queue
.
put
(
task
)
async
def
close
(
self
)
->
None
:
if
self
.
_closed
:
return
self
.
_closed
=
True
await
self
.
_queue
.
put
(
None
)
async
def
join
(
self
)
->
None
:
await
self
.
_queue
.
join
()
def
task_done
(
self
)
->
None
:
with
suppress
(
ValueError
):
self
.
_queue
.
task_done
()
def
__aiter__
(
self
)
->
AsyncIterator
[
RpcTask
]:
return
_QueueIterator
(
self
)
class
_QueueIterator
:
def
__init__
(
self
,
queue
:
InMemoryMessageQueue
)
->
None
:
self
.
_queue
=
queue
def
__aiter__
(
self
)
->
_QueueIterator
:
return
self
async
def
__anext__
(
self
)
->
RpcTask
:
item
=
await
self
.
_queue
.
_queue
.
get
()
if
item
is
None
:
self
.
_queue
.
task_done
()
raise
StopAsyncIteration
return
item
Back
|
FazBrowse Home
|
New Git URL