GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix synchronized methods to lock per-instance not per-method · ntworld/java2python@af2b2e4

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • java2python/mod/include
    • sync.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎java2python/mod/include/sync.py‎

Copy file name to clipboard
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
from threading import RLock
22

3-
_locks = {}
4-
def lock_for_object(obj, locks=_locks):
3+
def lock_for_object(obj, locks={}):
54
return locks.setdefault(id(obj), RLock())
65

7-
86
def synchronized(call):
7+
assert call.__code__.co_varnames[0] in {'self', 'cls'}
98
def inner(*args, **kwds):
10-
with lock_for_object(call):
9+
with lock_for_object(args[0]):
1110
return call(*args, **kwds)
1211
return inner

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.