waldiez 0.1.7__py3-none-any.whl → 0.1.8__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 waldiez might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  waldiez/__init__.py,sha256=AuVJ8ZOPmJoTeKQ_ryezU14tG-DFRb7djvr72a5G63Y,251
2
2
  waldiez/__main__.py,sha256=9xR-F2ohZcRPDG6KrM7cJpXciKX-u6WdL221ckyJ04k,112
3
- waldiez/_version.py,sha256=A8aXjNec6D58qEEhm4QLBRHEUMFlCl0k8_SIGteYnJ8,62
3
+ waldiez/_version.py,sha256=H1WLgLEQD6NHtFBb8DOYUVOZxL9vh2tPJJn9fu19O2k,62
4
4
  waldiez/cli.py,sha256=wStRkt056Y-F2CcuD6Zlov-ooUpWndyNesV9s_MjyHU,4798
5
5
  waldiez/exporter.py,sha256=iKe-l_Me8NRWsXHIdBcrOrnLT9XIyp4iYi4HLuuj2jA,9342
6
6
  waldiez/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -15,7 +15,7 @@ waldiez/exporting/agents/llm_config.py,sha256=A88e-RKp09r8n9MG11hArpITzxK8nVrTZ6
15
15
  waldiez/exporting/agents/teachability.py,sha256=ame4hHJCZRBp7hAQGZzv2Cjs6QtcV9vlQ1zheMEMac0,1103
16
16
  waldiez/exporting/agents/termination_message.py,sha256=tzI4-tcveYKBVx5PsznQZwAoghSX3mbn_vPu4rX8tuU,1276
17
17
  waldiez/exporting/agents/rag_user/__init__.py,sha256=01F4gwgUwtSpZbGXcfieqIuLNT64u9KiqMIB2f0mplI,196
18
- waldiez/exporting/agents/rag_user/chroma_utils.py,sha256=jBncfPsepTzgSo9wxyeLFEVvmoWDpIC-dJCpyqRQvx4,4632
18
+ waldiez/exporting/agents/rag_user/chroma_utils.py,sha256=4kZor8wgTaA7Mw9lUEHu594QtbTmiD2iZafhmOo7_9s,4579
19
19
  waldiez/exporting/agents/rag_user/mongo_utils.py,sha256=y5IL-Anfktg9cYo2o-ED1A7lwHQWdVMWD_W1AT5_RmE,2664
20
20
  waldiez/exporting/agents/rag_user/pgvector_utils.py,sha256=EyGDwvo1Pe8bqoJl3NFpqK6zizN81lPPaSMBMQF79Dc,2722
21
21
  waldiez/exporting/agents/rag_user/qdrant_utils.py,sha256=tn1A7pjQjJfGS33ALgnPYTz7xu8rVBidcc5-WHLq8e8,3487
@@ -24,7 +24,7 @@ waldiez/exporting/agents/rag_user/vector_db.py,sha256=64Gr_y1VTZLXi1pC4KjChsZ6DT
24
24
  waldiez/exporting/chats/__init__.py,sha256=v5aR1gWqSN5xeDDMIFo-ceC_Z9UgL8qJZofC2sU8HqQ,296
25
25
  waldiez/exporting/chats/chats.py,sha256=xI5ZzWpcqYz8Kuu7B9pU6iHN16wUwHxOvYFhH5vxWuA,1259
26
26
  waldiez/exporting/chats/helpers.py,sha256=K-IwBAG4-t7NLBP8Qs8_a2AEoKyoLw_B6eHzgXpOshA,13352
27
- waldiez/exporting/chats/nested.py,sha256=cDB22ekFrzBZj5eb-nM1oGfPc4BEDGrXTZT2AlNXRsQ,8356
27
+ waldiez/exporting/chats/nested.py,sha256=nYzxOTHSBpyFdqvX_NtZUvUgTdmoTZcCRaGTFzdnmII,7916
28
28
  waldiez/exporting/flow/__init__.py,sha256=WhdPrjXQAcihrS1KUtPNgbx0y1tqD5HtGykzpEAcsBM,98
29
29
  waldiez/exporting/flow/def_main.py,sha256=YpdhqO4iFng3r7if69ZPMJAibPVNDqnrOrWvGw7CJq8,1052
30
30
  waldiez/exporting/flow/flow.py,sha256=x2AlXr7aJJfrPMeuXQYfT9sG5GycMwf0kRkovZWKGag,6206
@@ -33,18 +33,14 @@ waldiez/exporting/skills/__init__.py,sha256=oIA9f5ABtYSbS0kMY_4ovU3-m6meVk5blEu_
33
33
  waldiez/exporting/utils/__init__.py,sha256=tP1V4g9-MyARlfOEL_1YWMJNW7UivUrrukq7DIwdq6k,1018
34
34
  waldiez/exporting/utils/comments.py,sha256=X9j8w48rh3DfFDjiMverU9DBSuE9yuMMbbStxBbN1sE,3190
35
35
  waldiez/exporting/utils/importing.py,sha256=dA4HCQ-OxmodUjovgXyLI9IwNvLwbY67P41969XoZ7g,8649
36
- waldiez/exporting/utils/logging_utils.py,sha256=uoV6O23lfB5ztOYEZiYu8Mn-2xEUwp_Qx404Mr62i7M,5822
36
+ waldiez/exporting/utils/logging_utils.py,sha256=DfnC13PqnadG0nRxz_gHA4IIZGnMawpTPlkKYdGT94w,5864
37
37
  waldiez/exporting/utils/method_utils.py,sha256=7-RUMTylNM2W0iM1bPX2_Gn3553XZSl2s2VGEijxNp4,891
38
38
  waldiez/exporting/utils/naming.py,sha256=VdoVODQduhXIs9hQFWUVEVqTaSyNDt7rkECsuIgXYwI,3196
39
39
  waldiez/exporting/utils/object_string.py,sha256=2kdIu4in3iUV92a2KbLWwp9POhvY-fzF_r2AGVnCKls,2166
40
40
  waldiez/exporting/utils/path_check.py,sha256=laGSLLiiwIIKxpAp5JIbtEvurbvXGkT4Hx0lemJcA9s,976
41
- waldiez/io/__init__.py,sha256=YczhIw0PKEsxCSY6tAqElCqOUh8b-aEkSIGC1JjXxAs,5877
42
- waldiez/io/stream/__init__.py,sha256=6qst5j2iXmV-wDTnhgCna3llqUfJ6tkR0HBq7Vx9x-Q,197
43
- waldiez/io/stream/consumer.py,sha256=VQDJEomYpGjmAtOoFBJrpCyoYzwykJUIOrdiLn08Uj4,4049
44
- waldiez/io/stream/provider.py,sha256=xcjtlZeeq7q-9fh0pSKCvAXv8vzPFrqbSGzfZCQoSFw,9607
45
- waldiez/io/stream/server.py,sha256=G3mUmfyswp6jQZAeqY3eemsuhRns1ls7nsMr27mdT6o,12614
41
+ waldiez/io/__init__.py,sha256=-w6ywIjG8ByxGtpSeRt1bjhnP4CZzpHf8WRWckjs4ng,5172
46
42
  waldiez/models/__init__.py,sha256=IMq8vzuAgmv92kHSSuZQLF38vVd31ojgOHonuHqWYj0,2888
47
- waldiez/models/waldiez.py,sha256=_odlEjyXPcvHXZVDq4wV0I3_bv27Syk3smBfMOUXIoU,9180
43
+ waldiez/models/waldiez.py,sha256=Oxav9QCYlkfxrNLlcJC89gT0UC4Ls5fTn4kL0PypyGw,9066
48
44
  waldiez/models/agents/__init__.py,sha256=3ZyVYBHMFzZjRMIdPrBF6HLg82LPAlEubL6utL6KhfU,1856
49
45
  waldiez/models/agents/agents.py,sha256=zIqihnoBjzaQLL_P6FcVoHddcusRNYsWPIFLZD091bE,3641
50
46
  waldiez/models/agents/agent/__init__.py,sha256=inA0zV3dnwmcQlcObH_FLaZSURjFG31E_XUampJAnJU,746
@@ -52,7 +48,7 @@ waldiez/models/agents/agent/agent.py,sha256=DAwreQtIdoM2x_vVccIkALl5whyS07GvfKRU
52
48
  waldiez/models/agents/agent/agent_data.py,sha256=A3qIvOKyUKBIqqPbsBKVE5JTNQ8JcoDEGMqazNkN_rA,5009
53
49
  waldiez/models/agents/agent/code_execution.py,sha256=kgL3pbEEyuMvJid0sIbfe4os7SWKpzL1Bv4O525Biyk,1942
54
50
  waldiez/models/agents/agent/linked_skill.py,sha256=8RHWHkHXqFuv7lEe1PuQoK1hTO3kBQ7ILKm9kCEWqNs,667
55
- waldiez/models/agents/agent/nested_chat.py,sha256=DAF3TCbTwyDvg6PGbeETtBLCQ4Xz5Saw5a4Xi-jr6jA,1929
51
+ waldiez/models/agents/agent/nested_chat.py,sha256=VKzHI38CUCnOlB6oBdO7CJdCk-wmG0aGXIkWpJPa4-Q,1757
56
52
  waldiez/models/agents/agent/teachability.py,sha256=IIR4LY9dwx3T7Ok17RYN2g6zGiga2gGizGteaeI3eGs,1703
57
53
  waldiez/models/agents/agent/termination_message.py,sha256=aGsIdwGs42BxDktkxoqHGEWM1wzhXr-zh_MlETsbycA,5674
58
54
  waldiez/models/agents/assistant/__init__.py,sha256=Zlf-4EI9HXl-LrqGosL7UucoyqIl74GZzohZlRLx2QI,175
@@ -88,8 +84,8 @@ waldiez/models/model/model_data.py,sha256=pDPKUbltaXWjCuDArgwTOEHw_igfk_DkxzFzdn
88
84
  waldiez/models/skill/__init__.py,sha256=rU88bajKOGMYoHFcE8MP0jW9H0MswbQmvz5wxS35BYE,169
89
85
  waldiez/models/skill/skill.py,sha256=fhsAI413an2_d4DBIkf7dzEuWk6rGs2t4sl97a4dj20,3473
90
86
  waldiez/models/skill/skill_data.py,sha256=RTWn8Od6w7g-nRIpsS29sqZ8sPm5dCPiK7-qXmU-KD4,815
91
- waldiez-0.1.7.dist-info/METADATA,sha256=dGnSmaGRqnsTogxJ9sp9SNg5rxpd6iBrkJEaGtC3kJM,7726
92
- waldiez-0.1.7.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
93
- waldiez-0.1.7.dist-info/entry_points.txt,sha256=5Po4yQXPa_QEdtTevpEBgr3rGoIvDMeQuJR2zqwBLBo,45
94
- waldiez-0.1.7.dist-info/licenses/LICENSE,sha256=VQEHM6WMQLRu1qaGl3GWsoOknDwro-69eGo4NLIJPIM,1064
95
- waldiez-0.1.7.dist-info/RECORD,,
87
+ waldiez-0.1.8.dist-info/METADATA,sha256=M3jPlHQhUMCvzgvm8LHzaBIjKl2GX8ARC-mtrsz90hE,8679
88
+ waldiez-0.1.8.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
89
+ waldiez-0.1.8.dist-info/entry_points.txt,sha256=5Po4yQXPa_QEdtTevpEBgr3rGoIvDMeQuJR2zqwBLBo,45
90
+ waldiez-0.1.8.dist-info/licenses/LICENSE,sha256=VQEHM6WMQLRu1qaGl3GWsoOknDwro-69eGo4NLIJPIM,1064
91
+ waldiez-0.1.8.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.25.0
2
+ Generator: hatchling 1.26.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,7 +0,0 @@
1
- """IO stream using twisted and sockets."""
2
-
3
- from .consumer import TCPConsumer
4
- from .provider import TCPProvider
5
- from .server import TCPServer
6
-
7
- __all__ = ["TCPServer", "TCPProvider", "TCPConsumer"]
@@ -1,139 +0,0 @@
1
- """TCP socket input consumer.
2
-
3
- It connects to a TCP server,
4
- listens for `INPUT:` messages to get the user's input,
5
- and sends `REQUEST:` messages to prompt the user,
6
- """
7
-
8
- import socket
9
- import time
10
- from types import TracebackType
11
- from typing import Optional, Type
12
-
13
- END_OF_MESSAGE = b"\r\n"
14
-
15
-
16
- class TCPConsumer:
17
- """TCP socket input consumer."""
18
-
19
- def __init__(
20
- self, host: str, port: int, timeout: Optional[float] = None
21
- ) -> None:
22
- """Create a new input consumer.
23
-
24
- Parameters
25
- ----------
26
- host : str
27
- The host to connect to.
28
- port : int
29
- The port to connect to.
30
- timeout : float, optional
31
- The timeout for the consumer, by default None (no timeout).
32
- """
33
- self.host = host
34
- self.port = port
35
- self.timeout = timeout
36
- self._running = False
37
- self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
38
-
39
- def __enter__(self) -> "TCPConsumer":
40
- """Enter the context."""
41
- self.start()
42
- return self
43
-
44
- def __exit__(
45
- self,
46
- exc_type: Optional[Type[BaseException]],
47
- exc_value: Optional[BaseException],
48
- traceback: Optional[TracebackType],
49
- ) -> None:
50
- """Exit the context."""
51
- self.stop()
52
-
53
- def is_running(self) -> bool:
54
- """Check if the consumer is running.
55
-
56
- Returns
57
- -------
58
- bool
59
- True is the consumer is running, else False
60
- """
61
- return self._running
62
-
63
- def start(self) -> None:
64
- """Start the consumer."""
65
- if self._running:
66
- return
67
- self._running = True
68
- self.socket.connect((self.host, self.port))
69
- self.socket.sendall("CONSUMER\r\n".encode("utf-8"))
70
-
71
- def _get_response_no_timeout(self) -> Optional[str]:
72
- """Get the response."""
73
- data = self.socket.recv(1024)
74
- while not data.endswith(END_OF_MESSAGE):
75
- data += self.socket.recv(1024)
76
- if data.startswith(b"INPUT:"):
77
- response = data[len(b"INPUT:") :]
78
- if response.endswith(END_OF_MESSAGE):
79
- response = response[: -len(END_OF_MESSAGE)]
80
- return response.decode("utf-8")
81
- return None
82
-
83
- def _get_response_with_timeout(self, timeout: float) -> Optional[str]:
84
- """Get the response using a timeout."""
85
- start_time = time.monotonic()
86
- data = b""
87
- self.socket.settimeout(timeout)
88
- while time.monotonic() - start_time < timeout:
89
- try:
90
- data += self.socket.recv(1024)
91
- except TimeoutError:
92
- return None
93
- if data.endswith(END_OF_MESSAGE):
94
- break
95
- if not data:
96
- return None
97
- if data.startswith(b"INPUT:"):
98
- response = data[len(b"INPUT:") :]
99
- if response.endswith(END_OF_MESSAGE):
100
- response = response[: -len(END_OF_MESSAGE)]
101
- return response.decode("utf-8")
102
- return None
103
-
104
- def get_response(self) -> Optional[str]:
105
- """Get the response.
106
-
107
- Returns
108
- -------
109
- Optional[str]
110
- The response if available, None otherwise.
111
- """
112
- if not self._running:
113
- self.start()
114
- if self.timeout is None or self.timeout < 1:
115
- return self._get_response_no_timeout()
116
- return self._get_response_with_timeout(self.timeout)
117
-
118
- def send_prompt(self, prompt: str) -> None:
119
- """Send a prompt.
120
-
121
- Parameters
122
- ----------
123
- prompt : str
124
- The prompt to send.
125
- """
126
- if not self._running:
127
- self.start()
128
- message = f"REQUEST:{prompt}" + "\r\n"
129
- self.socket.sendall(message.encode("utf-8"))
130
-
131
- def stop(self) -> None:
132
- """Close the consumer."""
133
- try:
134
- self.socket.close()
135
- except OSError:
136
- pass
137
- del self.socket
138
- self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
139
- self._running = False
@@ -1,343 +0,0 @@
1
- """TCP socket input provider.
2
-
3
- It connects to a TCP server,
4
- listens for `PROVIDE:` messages to receive prompts,
5
- and sends `USE:` messages to pass the response.
6
- """
7
-
8
- import logging
9
- import socket
10
- import threading
11
- import time
12
- from types import TracebackType
13
- from typing import Optional, Type
14
-
15
- END_OF_MESSAGE = b"\r\n"
16
- LOGGER = logging.getLogger("tcp::provider")
17
-
18
-
19
- class InputProviderThread(threading.Thread):
20
- """Input provider thread."""
21
-
22
- def __init__(
23
- self,
24
- host: str,
25
- port: int,
26
- response: Optional[str],
27
- timeout: Optional[float] = None,
28
- ) -> None:
29
- """Create a new input provider thread.
30
-
31
- Parameters
32
- ----------
33
- host : str
34
- The host to connect to.
35
- port : int
36
- The port to connect to.
37
- response : str, optional
38
- The response to send.
39
- timeout : float, optional
40
- The timeout for the provider, by default None (no timeout).
41
- """
42
- super().__init__(
43
- name="InputProviderThread",
44
- daemon=True,
45
- target=self.run,
46
- )
47
- self.host = host
48
- self.port = port
49
- self.timeout = timeout
50
- self._response = response
51
- self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
52
- self.running = False
53
-
54
- @property
55
- def response(self) -> Optional[str]:
56
- """Get the response."""
57
- return self._response
58
-
59
- @response.setter
60
- def response(self, response: str) -> None:
61
- """Set the response.
62
-
63
- Parameters
64
- ----------
65
- response : str
66
- The response to set.
67
- """
68
- self._response = response
69
-
70
- def _run_no_timeout(self) -> None:
71
- """Start the provider."""
72
- self.socket.connect((self.host, self.port))
73
- self.socket.sendall("PROVIDER\r\n".encode("utf-8"))
74
- self.running = True
75
- while self.running:
76
- data = b""
77
- while not data.endswith(END_OF_MESSAGE):
78
- try:
79
- data += self.socket.recv(1024)
80
- except BaseException: # pylint: disable=broad-except
81
- break
82
- if not data:
83
- break
84
- if data.startswith(b"PROVIDE:"):
85
- prompt = data[len(b"PROVIDE:") : -len(END_OF_MESSAGE)]
86
- LOGGER.debug("Got a prompt: %s", prompt)
87
- if self.response:
88
- message = f"USE:{self.response}" + "\r\n"
89
- self.socket.sendall(message.encode("utf-8"))
90
- self.socket.close()
91
- self.running = False
92
-
93
- def _run_with_timeout(self, timeout: float) -> None:
94
- """Start the provider with a timeout."""
95
- self.socket.connect((self.host, self.port))
96
- self.socket.sendall("PROVIDER\r\n".encode("utf-8"))
97
- self.running = True
98
- start_time = time.monotonic()
99
- while self.running:
100
- data = b""
101
- while time.monotonic() - start_time < timeout:
102
- try:
103
- data += self.socket.recv(1024)
104
- except BaseException: # pylint: disable=broad-except
105
- break
106
- if data.endswith(END_OF_MESSAGE):
107
- break
108
- if not data:
109
- break
110
- if data.startswith(b"PROVIDE:"):
111
- prompt = data[len(b"PROVIDE:") : -len(END_OF_MESSAGE)]
112
- LOGGER.debug("Got a prompt: %s", prompt)
113
- if self.response:
114
- message = f"USE:{self.response}" + "\r\n"
115
- self.socket.sendall(message.encode("utf-8"))
116
- self.socket.close()
117
- self.running = False
118
-
119
- def run(self) -> None:
120
- """Run the provider."""
121
- if self.timeout is None or self.timeout < 1:
122
- self._run_no_timeout()
123
- else:
124
- self._run_with_timeout(self.timeout)
125
-
126
-
127
- class InputProviderWrapper:
128
- """Input provider wrapper."""
129
-
130
- thread: Optional[InputProviderThread] = None
131
-
132
- def __init__(
133
- self,
134
- host: str,
135
- port: int,
136
- response: Optional[str] = None,
137
- timeout: Optional[float] = None,
138
- ) -> None:
139
- """Create a new input provider wrapper.
140
-
141
- Parameters
142
- ----------
143
- host : str
144
- The host to connect to.
145
- port : int
146
- The port to connect to.
147
- response : str, optional
148
- The response to send.
149
- timeout : float, optional
150
- The timeout for the provider, by default None (no timeout).
151
- """
152
- self._host = host
153
- self._port = port
154
- self._timeout = timeout
155
- self._response = response
156
-
157
- @property
158
- def response(self) -> Optional[str]:
159
- """Get the response."""
160
- if self.thread:
161
- return self.thread.response
162
- return self._response
163
-
164
- def start(self) -> None:
165
- """Start the provider."""
166
- self.thread = InputProviderThread(
167
- self._host, self._port, self._response, self._timeout
168
- )
169
- self.thread.daemon = True
170
- self.thread.start()
171
-
172
- def set_response(self, response: str) -> None:
173
- """Set the response.
174
-
175
- Parameters
176
- ----------
177
- response : str
178
- The response to set.
179
- """
180
- self._response = response
181
- if self.thread:
182
- self.thread.response = response
183
-
184
- def stop(self) -> None:
185
- """Stop the provider."""
186
- if self.thread:
187
- self.thread.running = False
188
- try:
189
- self.thread.socket.close()
190
- except OSError: # pragma: no cover
191
- pass
192
- self.thread.join(timeout=0)
193
- del self.thread
194
- self.thread = None
195
-
196
-
197
- class TCPProvider:
198
- """Input provider."""
199
-
200
- _wrapper: Optional[InputProviderWrapper] = None
201
-
202
- def __init__(
203
- self,
204
- host: str,
205
- port: int,
206
- response: Optional[str] = None,
207
- timeout: Optional[float] = 30,
208
- ) -> None:
209
- """Create a new input provider.
210
-
211
- Parameters
212
- ----------
213
- host : str
214
- The host to connect to.
215
- port : int
216
- The port to connect to.
217
- response : str, optional
218
- The response to send.
219
- timeout : float, optional
220
- The timeout for the provider, by default 30.
221
- """
222
- self._host = host
223
- self._port = port
224
- self._response = response
225
- self._timeout = timeout
226
- self._start_called = False
227
- self._init_wrapper()
228
-
229
- def __enter__(self) -> "TCPProvider":
230
- """Enter the context."""
231
- self.start()
232
- return self
233
-
234
- def __exit__(
235
- self,
236
- exc_type: Optional[Type[BaseException]],
237
- exc_value: Optional[BaseException],
238
- traceback: Optional[TracebackType],
239
- ) -> None:
240
- """Exit the context."""
241
- self.stop()
242
-
243
- @property
244
- def thread(self) -> Optional[InputProviderThread]:
245
- """Get the thread."""
246
- if not self._wrapper:
247
- return None
248
- return self._wrapper.thread
249
-
250
- @property
251
- def response(self) -> Optional[str]:
252
- """Get the response."""
253
- if self._wrapper:
254
- return self._wrapper.response
255
- return self._response
256
-
257
- def _init_wrapper(self) -> None:
258
- """Initialize the wrapper."""
259
- self._wrapper = InputProviderWrapper(
260
- host=self._host,
261
- port=self._port,
262
- response=self._response,
263
- timeout=self._timeout,
264
- )
265
-
266
- def is_running(self) -> bool:
267
- """Check if the provider is running.
268
-
269
- Returns
270
- -------
271
- bool
272
- True if the provider is running, False otherwise.
273
- """
274
- if not self._wrapper:
275
- return False
276
- if not self.thread:
277
- return False
278
- return self.thread.running is True
279
-
280
- def wait(self, timeout: float) -> None:
281
- """Wait until the provider is running.
282
-
283
- Parameters
284
- ----------
285
- timeout : float
286
- The timeout to wait.
287
- """
288
- start_time = time.time()
289
- while not self.is_running():
290
- if time.time() - start_time > timeout:
291
- break
292
- time.sleep(1)
293
-
294
- def start(self) -> None:
295
- """Start the provider.
296
-
297
- Raises
298
- ------
299
- RuntimeError
300
- If the wrapper is not initialized.
301
- """
302
- # avoid starting the provider multiple times
303
- # (if the wrapped thread has not yet started)
304
- if self._start_called is True:
305
- return
306
- self._start_called = True
307
- if self.is_running():
308
- return
309
- if not self._wrapper:
310
- raise RuntimeError("Wrapper not initialized")
311
- self._wrapper.start()
312
-
313
- def set_response(self, response: str) -> None:
314
- """Set the response.
315
-
316
- Parameters
317
- ----------
318
- response : str
319
- The response to set.
320
-
321
- Raises
322
- ------
323
- RuntimeError
324
- If the wrapper is not initialized.
325
- """
326
- if not self._wrapper:
327
- raise RuntimeError("Wrapper not initialized")
328
- self._wrapper.set_response(response or "\n")
329
-
330
- def stop(self) -> None:
331
- """Stop the provider."""
332
- self._start_called = False
333
- if not self.is_running():
334
- return
335
- if self._wrapper:
336
- self._wrapper.stop()
337
- del self._wrapper
338
- self._init_wrapper()
339
-
340
- def restart(self) -> None:
341
- """Restart the provider."""
342
- self.stop()
343
- self.start()