{"action":"created","issue":{"url":"https://api.github.com/repos/harvimt/quamash/issues/58","labels_url":"https://api.github.com/repos/harvimt/quamash/issues/58/labels{/name}","comments_url":"https://api.github.com/repos/harvimt/quamash/issues/58/comments","events_url":"https://api.github.com/repos/harvimt/quamash/issues/58/events","html_url":"https://github.com/harvimt/quamash/issues/58","id":121563202,"number":58,"title":"easycallback doctest is broken ?","user":{"login":"Insoleet","id":1170293,"avatar_url":"https://avatars.githubusercontent.com/u/1170293?v=3","gravatar_id":"","url":"https://api.github.com/users/Insoleet","html_url":"https://github.com/Insoleet","followers_url":"https://api.github.com/users/Insoleet/followers","following_url":"https://api.github.com/users/Insoleet/following{/other_user}","gists_url":"https://api.github.com/users/Insoleet/gists{/gist_id}","starred_url":"https://api.github.com/users/Insoleet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Insoleet/subscriptions","organizations_url":"https://api.github.com/users/Insoleet/orgs","repos_url":"https://api.github.com/users/Insoleet/repos","events_url":"https://api.github.com/users/Insoleet/events{/privacy}","received_events_url":"https://api.github.com/users/Insoleet/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-10T19:47:16Z","updated_at":"2016-01-02T05:30:41Z","closed_at":null,"body":"When I run pytest, I get : \r\n```\r\n2015-12-10 20:42:18,690 - DEBUG - quamash.QEventLoop - Adding reader callback for file descriptor 10\r\n2015-12-10 20:42:18,690 - DEBUG - quamash.QEventLoop - Running <generator object coro at 0x7f76c782b5a0> until complete\r\n2015-12-10 20:42:18,690 - DEBUG - quamash.QEventLoop - Registering callback <bound method Task._step of <Task pending coro=<coro() running at /home/inso/.pyenv/versions/3.4.3/lib/python3.4/asyncio/coroutines.py:139>>> to be invoked with arguments () after 0 second(s)\r\n2015-12-10 20:42:18,691 - DEBUG - quamash.QEventLoop - Adding callback <Handle Task._step()> with delay 0\r\n2015-12-10 20:42:18,691 - DEBUG - quamash.QEventLoop - Starting Qt event loop\r\n2015-12-10 20:42:18,691 - DEBUG - quamash.QEventLoop - Callback timer fired, calling <Handle Task._step()>\r\nTraceback (most recent call last):\r\n  File \"/home/inso/code/quamash/quamash/__init__.py\", line 214, in <lambda>\r\n    signaler.signal.connect(lambda self, args, kwargs: fn(self, *args, **kwargs))\r\n  File \"<doctest quamash._easycallback[5]>\", line 6, in mycallback\r\nAssertionError: assert <PyQt5.QtCore.QThread object at 0x7f76c7c74dc8> is not global_thread\r\n[1]    14537 abort (core dumped)  py.test -s tests/test_qeventloop.py\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/harvimt/quamash/issues/comments/168365238","html_url":"https://github.com/harvimt/quamash/issues/58#issuecomment-168365238","issue_url":"https://api.github.com/repos/harvimt/quamash/issues/58","id":168365238,"user":{"login":"harvimt","id":119106,"avatar_url":"https://avatars.githubusercontent.com/u/119106?v=3","gravatar_id":"","url":"https://api.github.com/users/harvimt","html_url":"https://github.com/harvimt","followers_url":"https://api.github.com/users/harvimt/followers","following_url":"https://api.github.com/users/harvimt/following{/other_user}","gists_url":"https://api.github.com/users/harvimt/gists{/gist_id}","starred_url":"https://api.github.com/users/harvimt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harvimt/subscriptions","organizations_url":"https://api.github.com/users/harvimt/orgs","repos_url":"https://api.github.com/users/harvimt/repos","events_url":"https://api.github.com/users/harvimt/events{/privacy}","received_events_url":"https://api.github.com/users/harvimt/received_events","type":"User","site_admin":false},"created_at":"2016-01-02T05:30:40Z","updated_at":"2016-01-02T05:30:40Z","body":"_easycallback will probably be removed in future versions of Quamash, so I\nwouldn't rely on it.\n\nThis code:\nhttps://github.com/harvimt/quamash/blob/depinject5realz/quamash/__init__.py#L133-L142\nis used instead.\n\nOn Thu, Dec 10, 2015 at 1:13 PM, Insoleet <notifications@github.com> wrote:\n\n> It seems that I have a problem with @easycallback . The test is broken,\n> but the following test, not using easycallback, runs nicely :\n>\n> import asyncio\n> import quamash\n> QThread, QObject = quamash.QtCore.QThread, quamash.QtCore.QObjectfrom PyQt5.QtCore import pyqtSignal\n> app = quamash.QApplication([])\n>\n> global_thread = QThread.currentThread()\n> called = Falseclass MyObject(QObject):\n>     def mycallback(self):\n>         global global_thread, mythread, called\n>         cur_thread = QThread.currentThread()\n>         assert cur_thread is not global_thread\n>         assert cur_thread is mythread\n>         called = True\n> class Signalizer(QObject):\n>     signaling = pyqtSignal()\n>\n> mythread = QThread()\n> mythread.start()\n> myobject = MyObject()\n> myobject.moveToThread(mythread)\n> signer = Signalizer()\n> signer.signaling.connect(myobject.mycallback)\n> @asyncio.coroutinedef mycoroutine():\n>     signer.signaling.emit()\n>\n> loop = quamash.QEventLoop(app)\n> asyncio.set_event_loop(loop)with loop:\n>     loop.run_until_complete(mycoroutine())assert called is True\n>\n> I'm using PyQt5 5.5.1 and python 3.4.3.\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/harvimt/quamash/issues/58#issuecomment-163750733>.\n>\n"}}