Skip to content

Commit

Permalink
Correctly spawn flet server process
Browse files Browse the repository at this point in the history
  • Loading branch information
FeodorFitsner committed Apr 8, 2022
1 parent 2bafb46 commit 957bda7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
# Dependency directories (remove the comment below to include it)
# vendor/

server/content/
# mac specific
.DS_Store
2 changes: 2 additions & 0 deletions client/macos/Runner/DebugProfile.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
2 changes: 2 additions & 0 deletions client/macos/Runner/Release.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
5 changes: 4 additions & 1 deletion sdk/python/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,7 @@ dmypy.json

# PDM
.pdm.toml
__pypackages__/
__pypackages__/

# bin
flet/bin/
18 changes: 12 additions & 6 deletions sdk/python/flet/flet.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,20 @@ def _start_flet_server(port, attached):
else:
logging.info(f"Flet Server found in PATH")

flet_env = {**os.environ, "FLET_LOG_TO_FILE": "true"}
# flet_env = {**os.environ, "FLET_LOG_TO_FILE": "true"}

args = [flet_path, "server", "--port", str(port)]

creationflags = subprocess.CREATE_NEW_PROCESS_GROUP
creationflags = 0
start_new_session = False

if attached:
args.append("--attached")
creationflags = 0
else:
if is_windows():
creationflags = subprocess.CREATE_NEW_PROCESS_GROUP
else:
start_new_session = True

log_level = logging.getLogger().getEffectiveLevel()
if log_level == logging.CRITICAL:
Expand All @@ -240,10 +245,11 @@ def _start_flet_server(port, attached):

subprocess.Popen(
args,
env=flet_env,
# env=flet_env,
creationflags=creationflags,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
start_new_session=start_new_session,
stdout=subprocess.DEVNULL if log_level >= logging.WARNING else None,
stderr=subprocess.DEVNULL if log_level >= logging.WARNING else None,
)

return port
Expand Down

0 comments on commit 957bda7

Please sign in to comment.