aboutsummaryrefslogtreecommitdiffstats
path: root/examples/network/blockingfortuneclient/blockingfortuneclient.py
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2022-01-26 19:03:41 +0100
committerChristian Tismer <tismer@stackless.com>2022-02-03 14:06:06 +0100
commitbc11e3c074bdba1ae0fcaa0c10e3b32f781be9fd (patch)
tree7658d78ab1241e6570f6c8ac2f7f27a0b4dbbbc9 /examples/network/blockingfortuneclient/blockingfortuneclient.py
parent0cfddaa56fb560c4ffb3809b7924a0fbb6f3889f (diff)
PyPySide: Fix locker handling which enables Mandelbrot
Not only the QPainter, but also the QMutexLocker were not correctly modelled after PEP 343 in the examples. Since that is now fixed, we consider the PyPy project not as ready, but good enough to publish it. It also turned out that people have the expectation to use QSignalBlocker in the "as" form: with QSignalBlocker(self.double_spin_box) as blocker: self.double_spin_box.setValue(2.5) https://stackoverflow.com/questions/60384734/how-to-use-qsignalblocker-in-python But that blocker would be None. As a side effect, QMutexLocker, QReadLocker, QWriteLocker and QSignalBlocker were augmented with a default __enter__ implementation that returns the locker instance. [ChangeLog][PySide6] The Mandelbrot example needed context managers for QPainter and QMutexLocker to work in PyPy. Task-number: PYSIDE-535 Pick-to: 6.2 Change-Id: I2a62ca645a4fddcafbf11869f14a538141f32c39 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'examples/network/blockingfortuneclient/blockingfortuneclient.py')
-rw-r--r--examples/network/blockingfortuneclient/blockingfortuneclient.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/examples/network/blockingfortuneclient/blockingfortuneclient.py b/examples/network/blockingfortuneclient/blockingfortuneclient.py
index 50f4c1662..b997a8f7d 100644
--- a/examples/network/blockingfortuneclient/blockingfortuneclient.py
+++ b/examples/network/blockingfortuneclient/blockingfortuneclient.py
@@ -73,13 +73,13 @@ class FortuneThread(QThread):
self.wait()
def request_new_fortune(self, hostname, port):
- locker = QMutexLocker(self.mutex)
- self._host_name = hostname
- self.port = port
- if not self.isRunning():
- self.start()
- else:
- self.cond.wakeOne()
+ with QMutexLocker(self.mutex):
+ self._host_name = hostname
+ self.port = port
+ if not self.isRunning():
+ self.start()
+ else:
+ self.cond.wakeOne()
def run(self):
self.mutex.lock()