File tree Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Original file line number Diff line number Diff line change
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
Original file line number Diff line number Diff line change
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from __future__ import annotations
16
+
17
+ import threading
18
+ from typing import Callable
19
+
20
+ internal_thread = None
21
+ try :
22
+ from .internal import thread as internal_thread
23
+ except ImportError :
24
+ internal_thread = None
25
+
26
+
27
+ def create_thread (target : Callable [..., None ], * args , ** kwargs ):
28
+ """Creates a thread."""
29
+ if internal_thread :
30
+ return internal_thread .create_thread (target , * args , ** kwargs )
31
+ return threading .Thread (target = target , args = args , kwargs = kwargs )
Original file line number Diff line number Diff line change 38
38
from .events .event import Event
39
39
from .memory .base_memory_service import BaseMemoryService
40
40
from .memory .in_memory_memory_service import InMemoryMemoryService
41
+ from .platform .thread import create_thread
41
42
from .sessions .base_session_service import BaseSessionService
42
43
from .sessions .in_memory_session_service import InMemorySessionService
43
44
from .sessions .session import Session
@@ -139,7 +140,7 @@ def _asyncio_thread_main():
139
140
finally :
140
141
event_queue .put (None )
141
142
142
- thread = threading . Thread (target = _asyncio_thread_main )
143
+ thread = create_thread (target = _asyncio_thread_main )
143
144
thread .start ()
144
145
145
146
# consumes and re-yield the events from background thread.
You can’t perform that action at this time.
0 commit comments