reflex 0.8.3a1__py3-none-any.whl → 0.8.3a2__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 reflex might be problematic. Click here for more details.

reflex/testing.py CHANGED
@@ -24,8 +24,6 @@ from io import TextIOWrapper
24
24
  from pathlib import Path
25
25
  from typing import TYPE_CHECKING, Any, Literal, TypeVar
26
26
 
27
- import psutil
28
-
29
27
  import reflex
30
28
  import reflex.reflex
31
29
  import reflex.utils.exec
@@ -105,6 +103,24 @@ class ReflexProcessExitNonZeroError(RuntimeError):
105
103
  """Exception raised when the reflex process exits with a non-zero status."""
106
104
 
107
105
 
106
+ def _is_port_responsive(port: int) -> bool:
107
+ """Check if a port is responsive.
108
+
109
+ Args:
110
+ port: the port to check
111
+
112
+ Returns:
113
+ True if the port is responsive, False otherwise
114
+ """
115
+ try:
116
+ with contextlib.closing(
117
+ socket.socket(socket.AF_INET, socket.SOCK_STREAM)
118
+ ) as sock:
119
+ return sock.connect_ex(("127.0.0.1", port)) == 0
120
+ except (OverflowError, PermissionError, OSError):
121
+ return False
122
+
123
+
108
124
  @dataclasses.dataclass
109
125
  class AppHarness:
110
126
  """AppHarness executes a reflex app in-process for testing."""
@@ -366,29 +382,28 @@ class AppHarness:
366
382
  msg = "Reflex process has no pid."
367
383
  raise RuntimeError(msg)
368
384
 
385
+ if backend and self.backend_port is None:
386
+ msg = "Backend port is not set."
387
+ raise RuntimeError(msg)
388
+
389
+ if frontend and self.frontend_port is None:
390
+ msg = "Frontend port is not set."
391
+ raise RuntimeError(msg)
392
+
369
393
  frontend_ready = False
370
394
  backend_ready = False
371
- timeout = 30
372
- start_time = time.time()
373
395
 
374
- process = psutil.Process(self.reflex_process.pid)
375
396
  while not ((not frontend or frontend_ready) and (not backend or backend_ready)):
376
- if time.time() - start_time > timeout:
377
- msg = f"Timeout waiting for servers. Frontend ready: {frontend_ready}, Backend ready: {backend_ready}"
378
- raise RuntimeError(msg)
379
-
380
- for proc in process.children(recursive=True):
381
- with contextlib.suppress(psutil.NoSuchProcess, psutil.AccessDenied):
382
- if ncs := proc.net_connections():
383
- for net_conn in ncs:
384
- if net_conn.status == psutil.CONN_LISTEN:
385
- if net_conn.laddr.port == self.frontend_port:
386
- frontend_ready = True
387
- self.frontend_url = (
388
- f"http://localhost:{self.frontend_port}/"
389
- )
390
- elif net_conn.laddr.port == self.backend_port:
391
- backend_ready = True
397
+ if backend and self.backend_port and _is_port_responsive(self.backend_port):
398
+ backend_ready = True
399
+ if (
400
+ frontend
401
+ and self.frontend_port
402
+ and _is_port_responsive(self.frontend_port)
403
+ ):
404
+ frontend_ready = True
405
+ self.frontend_url = f"http://localhost:{self.frontend_port}/"
406
+ time.sleep(POLL_INTERVAL)
392
407
 
393
408
  async def _reset_backend_state_manager(self):
394
409
  """Reset the StateManagerRedis event loop affinity.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reflex
3
- Version: 0.8.3a1
3
+ Version: 0.8.3a2
4
4
  Summary: Web apps in pure Python.
5
5
  Project-URL: homepage, https://reflex.dev
6
6
  Project-URL: repository, https://github.com/reflex-dev/reflex
@@ -15,7 +15,7 @@ reflex/reflex.py,sha256=1sRT6INn5ZdbPZAL-g5C9hU6ZwMEMHJV6gUvNTx3KSg,22616
15
15
  reflex/route.py,sha256=UfhKxFwe3EYto66TZv5K2Gp6ytRbcL-_v72DJ5girEs,7691
16
16
  reflex/state.py,sha256=mrYV9wEdJ9DdWbAadgdWHbxc6onOU56dT8f4zkbznPo,92127
17
17
  reflex/style.py,sha256=JxbXXA4MTnXrk0XHEoMBoNC7J-M2oL5Hl3W_QmXvmBg,13222
18
- reflex/testing.py,sha256=_3RaedM2tJEmZpzEce0AixYBv7lYtCS52pcFHoVVzo0,35025
18
+ reflex/testing.py,sha256=92KUvlXE9w0N4IhqVOEOF8gIFJGuRxj7edeSWJrPGgk,35092
19
19
  reflex/.templates/apps/blank/assets/favicon.ico,sha256=baxxgDAQ2V4-G5Q4S2yK5uUJTUGkv-AOWBQ0xd6myUo,4286
20
20
  reflex/.templates/apps/blank/code/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
21
  reflex/.templates/apps/blank/code/blank.py,sha256=wry9E3VjC7qtt_gzqNOyo4KZAAlzVyNp3uhFkcLZmM0,898
@@ -401,8 +401,8 @@ reflex/vars/number.py,sha256=tO7pnvFaBsedq1HWT4skytnSqHWMluGEhUbjAUMx8XQ,28190
401
401
  reflex/vars/object.py,sha256=BDmeiwG8v97s_BnR1Egq3NxOKVjv9TfnREB3cz0zZtk,17322
402
402
  reflex/vars/sequence.py,sha256=1kBrqihspyjyQ1XDqFPC8OpVGtZs_EVkOdIKBro5ilA,55249
403
403
  scripts/hatch_build.py,sha256=-4pxcLSFmirmujGpQX9UUxjhIC03tQ_fIQwVbHu9kc0,1861
404
- reflex-0.8.3a1.dist-info/METADATA,sha256=q-R6r0BXinptbZJV_2s1I5US8zOsqkEb-1_TVlHf6R4,12371
405
- reflex-0.8.3a1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
406
- reflex-0.8.3a1.dist-info/entry_points.txt,sha256=Rxt4dXc7MLBNt5CSHTehVPuSe9Xqow4HLX55nD9tQQ0,45
407
- reflex-0.8.3a1.dist-info/licenses/LICENSE,sha256=dw3zLrp9f5ObD7kqS32vWfhcImfO52PMmRqvtxq_YEE,11358
408
- reflex-0.8.3a1.dist-info/RECORD,,
404
+ reflex-0.8.3a2.dist-info/METADATA,sha256=EXg7yHNzrGXELUGgv9wt1N8WikdQ3NDHBzPsqqR2I_k,12371
405
+ reflex-0.8.3a2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
406
+ reflex-0.8.3a2.dist-info/entry_points.txt,sha256=Rxt4dXc7MLBNt5CSHTehVPuSe9Xqow4HLX55nD9tQQ0,45
407
+ reflex-0.8.3a2.dist-info/licenses/LICENSE,sha256=dw3zLrp9f5ObD7kqS32vWfhcImfO52PMmRqvtxq_YEE,11358
408
+ reflex-0.8.3a2.dist-info/RECORD,,