|
36 | 36 | from ._bolt import (
|
37 | 37 | AsyncBolt,
|
38 | 38 | ServerStateManagerBase,
|
| 39 | + tx_timeout_as_ms, |
39 | 40 | )
|
40 | 41 | from ._bolt3 import (
|
41 | 42 | ServerStateManager,
|
@@ -212,12 +213,7 @@ def run(self, query, parameters=None, mode=None, bookmarks=None,
|
212 | 213 | except TypeError:
|
213 | 214 | raise TypeError("Metadata must be coercible to a dict")
|
214 | 215 | if timeout is not None:
|
215 |
| - try: |
216 |
| - extra["tx_timeout"] = int(1000 * float(timeout)) |
217 |
| - except TypeError: |
218 |
| - raise TypeError("Timeout must be specified as a number of seconds") |
219 |
| - if extra["tx_timeout"] < 0: |
220 |
| - raise ValueError("Timeout must be a positive number or 0.") |
| 216 | + extra["tx_timeout"] = tx_timeout_as_ms(timeout) |
221 | 217 | fields = (query, parameters, extra)
|
222 | 218 | log.debug("[#%04X] C: RUN %s", self.local_port, " ".join(map(repr, fields)))
|
223 | 219 | self._append(b"\x10", fields,
|
@@ -276,12 +272,7 @@ def begin(self, mode=None, bookmarks=None, metadata=None, timeout=None,
|
276 | 272 | except TypeError:
|
277 | 273 | raise TypeError("Metadata must be coercible to a dict")
|
278 | 274 | if timeout is not None:
|
279 |
| - try: |
280 |
| - extra["tx_timeout"] = int(1000 * float(timeout)) |
281 |
| - except TypeError: |
282 |
| - raise TypeError("Timeout must be specified as a number of seconds") |
283 |
| - if extra["tx_timeout"] < 0: |
284 |
| - raise ValueError("Timeout must be a positive number or 0.") |
| 275 | + extra["tx_timeout"] = tx_timeout_as_ms(timeout) |
285 | 276 | log.debug("[#%04X] C: BEGIN %r", self.local_port, extra)
|
286 | 277 | self._append(b"\x11", (extra,),
|
287 | 278 | Response(self, "begin", hydration_hooks, **handlers),
|
@@ -555,12 +546,7 @@ def run(self, query, parameters=None, mode=None, bookmarks=None,
|
555 | 546 | except TypeError:
|
556 | 547 | raise TypeError("Metadata must be coercible to a dict")
|
557 | 548 | if timeout is not None:
|
558 |
| - try: |
559 |
| - extra["tx_timeout"] = int(1000 * float(timeout)) |
560 |
| - except TypeError: |
561 |
| - raise TypeError("Timeout must be specified as a number of seconds") |
562 |
| - if extra["tx_timeout"] < 0: |
563 |
| - raise ValueError("Timeout must be a positive number or 0.") |
| 549 | + extra["tx_timeout"] = tx_timeout_as_ms(timeout) |
564 | 550 | fields = (query, parameters, extra)
|
565 | 551 | log.debug("[#%04X] C: RUN %s", self.local_port,
|
566 | 552 | " ".join(map(repr, fields)))
|
@@ -596,12 +582,7 @@ def begin(self, mode=None, bookmarks=None, metadata=None, timeout=None,
|
596 | 582 | except TypeError:
|
597 | 583 | raise TypeError("Metadata must be coercible to a dict")
|
598 | 584 | if timeout is not None:
|
599 |
| - try: |
600 |
| - extra["tx_timeout"] = int(1000 * float(timeout)) |
601 |
| - except TypeError: |
602 |
| - raise TypeError("Timeout must be specified as a number of seconds") |
603 |
| - if extra["tx_timeout"] < 0: |
604 |
| - raise ValueError("Timeout must be a positive number or 0.") |
| 585 | + extra["tx_timeout"] = tx_timeout_as_ms(timeout) |
605 | 586 | log.debug("[#%04X] C: BEGIN %r", self.local_port, extra)
|
606 | 587 | self._append(b"\x11", (extra,),
|
607 | 588 | Response(self, "begin", hydration_hooks, **handlers),
|
|
0 commit comments