{"action":"created","issue":{"url":"https://api.github.com/repos/kivy/kivy/issues/4744","repository_url":"https://api.github.com/repos/kivy/kivy","labels_url":"https://api.github.com/repos/kivy/kivy/issues/4744/labels{/name}","comments_url":"https://api.github.com/repos/kivy/kivy/issues/4744/comments","events_url":"https://api.github.com/repos/kivy/kivy/issues/4744/events","html_url":"https://github.com/kivy/kivy/issues/4744","id":190567279,"node_id":"MDU6SXNzdWUxOTA1NjcyNzk=","number":4744,"title":"Multiprocessing opens unwanted windows (on windows only, pyinstaller)","user":{"login":"TimSC","id":995844,"node_id":"MDQ6VXNlcjk5NTg0NA==","avatar_url":"https://avatars3.githubusercontent.com/u/995844?v=4","gravatar_id":"","url":"https://api.github.com/users/TimSC","html_url":"https://github.com/TimSC","followers_url":"https://api.github.com/users/TimSC/followers","following_url":"https://api.github.com/users/TimSC/following{/other_user}","gists_url":"https://api.github.com/users/TimSC/gists{/gist_id}","starred_url":"https://api.github.com/users/TimSC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TimSC/subscriptions","organizations_url":"https://api.github.com/users/TimSC/orgs","repos_url":"https://api.github.com/users/TimSC/repos","events_url":"https://api.github.com/users/TimSC/events{/privacy}","received_events_url":"https://api.github.com/users/TimSC/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":26,"created_at":"2016-11-20T16:20:21Z","updated_at":"2019-01-04T05:12:07Z","closed_at":"2016-11-25T14:16:50Z","author_association":"NONE","body":"I am trying to using multiprocessing with kivy. It works fine on linux, but on windows I had to put the kivy imports within the \"__name__ == '__main__'\" section, otherwise it tends to open more blank windows, which I don't want. Is this the best approach?\r\n\r\nMy problem is that when I package this using pyinstaller, the above work around is not effective and the program keeps spawning new windows. (I had to use a trunk build of pyinstaller due to https://stackoverflow.com/questions/36400111/pyinstaller-doesnt-import-queue/40706162 )\r\n\r\nIn python 2.7:\r\n\r\n\timport multiprocessing, time\r\n\timport future\r\n\tfrom queue import Empty\r\n\r\n\tdef MyFunc(queue, queue2):\r\n\t\tcount = 0\r\n\t\trunning = True\r\n\t\twhile running:\r\n\t\t\ttry:\r\n\t\t\t\tmsg = queue2.get(True, 1.0)\r\n\t\t\t\tprint (msg)\r\n\t\t\t\tif msg == \"stop\":\r\n\t\t\t\t\trunning = False\r\n\t\t\texcept Empty:\r\n\t\t\t\tpass\r\n\t\t\tcount += 1\r\n\t\t\tqueue.put(count)\r\n\r\n\tif __name__ == '__main__':\r\n\t\timport kivy\r\n\t\tkivy.require('1.9.0') # replace with your current kivy version !\r\n\r\n\t\tfrom kivy.app import App\r\n\t\tfrom kivy.uix.label import Label\r\n\t\tfrom kivy.clock import Clock\r\n\t\r\n\t\tclass MyApp(App):\r\n\r\n\t\t\tdef build(self):\r\n\t\t\t\tself.queue = multiprocessing.Queue()\r\n\t\t\t\tself.queue2 = multiprocessing.Queue()\r\n\t\t\t\tself.p = multiprocessing.Process(target=MyFunc, args=(self.queue, self.queue2))\r\n\t\t\t\tself.p.start()\r\n\t\t\r\n\t\t\t\tClock.schedule_interval(self.idle, 0.1)\r\n\t\t\r\n\t\t\t\tself.lbl = Label(text='Hello world')\r\n\t\t\t\treturn self.lbl\r\n\r\n\t\t\tdef idle(self, dt):\r\n\t\t\t\ttry:\r\n\t\t\t\t\twhile True:\r\n\t\t\t\t\t\tmsg = self.queue.get_nowait()\r\n\t\t\t\t\t\tself.lbl.text = str(msg)\r\n\t\t\t\texcept Empty:\r\n\t\t\t\t\tpass\r\n\t\t\r\n\t\tmyApp = MyApp()\r\n\t\tmyApp.run()\r\n\t\t\r\n\t\tmyApp.queue2.put(\"stop\")\r\n\t\tmyApp.p.join()\r\n\r\nBasic problem and partial work around discussed back in 2014: https://groups.google.com/d/msg/kivy-users/mkW2deHqZGI/pfc_4tusWtwJ"},"comment":{"url":"https://api.github.com/repos/kivy/kivy/issues/comments/451354919","html_url":"https://github.com/kivy/kivy/issues/4744#issuecomment-451354919","issue_url":"https://api.github.com/repos/kivy/kivy/issues/4744","id":451354919,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MTM1NDkxOQ==","user":{"login":"haveityourwa","id":13549887,"node_id":"MDQ6VXNlcjEzNTQ5ODg3","avatar_url":"https://avatars3.githubusercontent.com/u/13549887?v=4","gravatar_id":"","url":"https://api.github.com/users/haveityourwa","html_url":"https://github.com/haveityourwa","followers_url":"https://api.github.com/users/haveityourwa/followers","following_url":"https://api.github.com/users/haveityourwa/following{/other_user}","gists_url":"https://api.github.com/users/haveityourwa/gists{/gist_id}","starred_url":"https://api.github.com/users/haveityourwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haveityourwa/subscriptions","organizations_url":"https://api.github.com/users/haveityourwa/orgs","repos_url":"https://api.github.com/users/haveityourwa/repos","events_url":"https://api.github.com/users/haveityourwa/events{/privacy}","received_events_url":"https://api.github.com/users/haveityourwa/received_events","type":"User","site_admin":false},"created_at":"2019-01-04T05:12:07Z","updated_at":"2019-01-04T05:12:07Z","author_association":"NONE","body":"Not sure if I should bring to life a dead thread, however I am also having issues when trying to use multiprocessing to call a function. My issue is that each time I call an asycn function it launches a window. I tried placing \r\n```\r\nif __name__ == '__main__':\r\n\tmultiprocessing.freeze_support()\r\n```\r\nabove the rest of my application like so.\r\n```\r\nimport multiprocessing\r\nimport time\r\n\r\n\r\ndef psse_run():\r\n    time.sleep(1)\r\n\r\n\r\nif __name__ == '__main__':\r\n    multiprocessing.freeze_support()\r\n\r\nimport kivy\r\n```\r\nHowever it will still launch a blank window when called like so.\r\n```\r\npool = Pool(processes=1)\r\npool.apply_async(psse_run, ())\r\n```\r\nIn general I want to be able to use the Kivy application to work on files in the background however this is posing more of an issue then I was expecting."}}
{"actor":{"display_login":"haveityourwa"}}