Code Monkey home page Code Monkey logo

Comments (3)

Insoleet avatar Insoleet commented on September 25, 2024

It seems that I have a problem with @easycallback . The test is broken, but the following test, not using easycallback, runs nicely :

import asyncio

import quamash
QThread, QObject = quamash.QtCore.QThread, quamash.QtCore.QObject
from PyQt5.QtCore import pyqtSignal
app = quamash.QApplication([])

global_thread = QThread.currentThread()
called = False
class MyObject(QObject):
    def mycallback(self):
        global global_thread, mythread, called
        cur_thread = QThread.currentThread()
        assert cur_thread is not global_thread
        assert cur_thread is mythread
        called = True

class Signalizer(QObject):
    signaling = pyqtSignal()

mythread = QThread()
mythread.start()
myobject = MyObject()
myobject.moveToThread(mythread)
signer = Signalizer()
signer.signaling.connect(myobject.mycallback)

@asyncio.coroutine
def mycoroutine():
    signer.signaling.emit()

loop = quamash.QEventLoop(app)
asyncio.set_event_loop(loop)
with loop:
    loop.run_until_complete(mycoroutine())
assert called is True

I'm using PyQt5 5.5.1 and python 3.4.3.

If connect this custom Signaler with using a lambda, I get an error again :

signer.signaling.connect(lambda: myobject.mycallback())
(cutecoin) ➜  quamash git:(master) ✗ python bug.py
Traceback (most recent call last):
  File "bug.py", line 28, in <lambda>
    signer.signaling.connect(lambda: myobject.mycallback())
  File "bug.py", line 16, in mycallback
    assert cur_thread is not global_thread
AssertionError

This bug seems present on windows : https://ci.appveyor.com/project/harvimt/quamash/branch/master/job/48blugynxumjoo5p

from quamash.

harvimt avatar harvimt commented on September 25, 2024

_easycallback will probably be removed in future versions of Quamash, so I
wouldn't rely on it.

This code:
https://github.com/harvimt/quamash/blob/depinject5realz/quamash/__init__.py#L133-L142
is used instead.

On Thu, Dec 10, 2015 at 1:13 PM, Insoleet [email protected] wrote:

It seems that I have a problem with @easycallback . The test is broken,
but the following test, not using easycallback, runs nicely :

import asyncio
import quamash
QThread, QObject = quamash.QtCore.QThread, quamash.QtCore.QObjectfrom PyQt5.QtCore import pyqtSignal
app = quamash.QApplication([])

global_thread = QThread.currentThread()
called = Falseclass MyObject(QObject):
def mycallback(self):
global global_thread, mythread, called
cur_thread = QThread.currentThread()
assert cur_thread is not global_thread
assert cur_thread is mythread
called = True
class Signalizer(QObject):
signaling = pyqtSignal()

mythread = QThread()
mythread.start()
myobject = MyObject()
myobject.moveToThread(mythread)
signer = Signalizer()
signer.signaling.connect(myobject.mycallback)
@asyncio.coroutinedef mycoroutine():
signer.signaling.emit()

loop = quamash.QEventLoop(app)
asyncio.set_event_loop(loop)with loop:
loop.run_until_complete(mycoroutine())assert called is True

I'm using PyQt5 5.5.1 and python 3.4.3.


Reply to this email directly or view it on GitHub
#58 (comment).

from quamash.

harvimt avatar harvimt commented on September 25, 2024

and by probably I mean the next version 😄

from quamash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.