Skip to content

[Bug]: Playwright fails in free threading 3.14 #3123

Description

@ddorian

Version

1.60.0

Steps to reproduce

uv run --no-project --python 3.14t repro.py
# /// script
# requires-python = ">=3.14"
# dependencies = [
#   "playwright==1.60.0",
#   "greenlet==3.5.2",
# ]
# ///

import sys

print(f"python {sys.version.split()[0]}  gil_enabled={sys._is_gil_enabled()}", flush=True)

from playwright.sync_api import sync_playwright

for i in range(12):
    with sync_playwright() as p:
        browser = p.firefox.launch()
        page = browser.new_page()
        page.set_content("<h1>hello</h1>")
        page.title()
        browser.close()
    print("iter", i, "ok", flush=True)

print("DONE no crash")

Expected behavior

I expect it to work?

Actual behavior

uv run --no-project --python 3.14t repro.py
Installed 4 packages in 6ms
python 3.14.6  gil_enabled=False
Fatal Python error: PyMutex_Unlock: unlocking mutex that is not locked
Python runtime state: initialized

Stack (most recent call first):
  File "/home/guru/.local/share/uv/python/cpython-3.14.6+freethreaded-linux-x86_64-gnu/lib/python3.14t/tokenize.py", line 461 in open
  File "/home/guru/.local/share/uv/python/cpython-3.14.6+freethreaded-linux-x86_64-gnu/lib/python3.14t/linecache.py", line 187 in updatecache
  File "/home/guru/.local/share/uv/python/cpython-3.14.6+freethreaded-linux-x86_64-gnu/lib/python3.14t/linecache.py", line 41 in getlines
  File "/home/guru/.local/share/uv/python/cpython-3.14.6+freethreaded-linux-x86_64-gnu/lib/python3.14t/linecache.py", line 26 in getline
  File "/home/guru/.local/share/uv/python/cpython-3.14.6+freethreaded-linux-x86_64-gnu/lib/python3.14t/traceback.py", line 352 in _set_lines
  File "/home/guru/.local/share/uv/python/cpython-3.14.6+freethreaded-linux-x86_64-gnu/lib/python3.14t/traceback.py", line 374 in line
  File "/home/guru/.local/share/uv/python/cpython-3.14.6+freethreaded-linux-x86_64-gnu/lib/python3.14t/traceback.py", line 505 in _extract_from_extended_frame_gen
  File "/home/guru/.local/share/uv/python/cpython-3.14.6+freethreaded-linux-x86_64-gnu/lib/python3.14t/traceback.py", line 454 in extract
  File "/home/guru/.local/share/uv/python/cpython-3.14.6+freethreaded-linux-x86_64-gnu/lib/python3.14t/traceback.py", line 261 in extract_stack
  File "/home/guru/.cache/uv/environments-v2/repro-4663f0fd0134bc62/lib/python3.14t/site-packages/playwright/_impl/_sync_base.py", line 109 in _sync
  File "/home/guru/.cache/uv/environments-v2/repro-4663f0fd0134bc62/lib/python3.14t/site-packages/playwright/sync_api/_generated.py", line 16269 in launch
  File "/home/guru/Desktop/the_stream/stream-2/repro.py", line 43 in <module>

Extension modules: greenlet._greenlet (total: 1)

Additional context

No response

Environment

- Operating System: [Ubuntu 22.04]
- CPU: [arm64]
- Browser: [All, Chromium, Firefox, WebKit]
- Python Version: [3.12]
- Other info:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions