reclosedev / async_gui Goto Github PK
View Code? Open in Web Editor NEWEasy threading and multiprocessing for GUI applications
Home Page: https://pypi.python.org/pypi/async_gui/
License: BSD 2-Clause "Simplified" License
Easy threading and multiprocessing for GUI applications
Home Page: https://pypi.python.org/pypi/async_gui/
License: BSD 2-Clause "Simplified" License
Hi guys your lib in https://pypi.org/project/async_gui/ is not the latest version, Kivy is not include
I got this traceback while runn async_gui in a Pyside app:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\async_gui\engine.py", line 81, in wrapper
return self.create_runner(gen).run()
File "C:\Python27\lib\site-packages\async_gui\engine.py", line 136, in run
task = self._execute_single_task(gen, executor, task)
File "C:\Python27\lib\site-packages\async_gui\engine.py", line 149, in _execute_single_task
self.engine.update_gui()
File "C:\Python27\lib\site-packages\async_gui\toolkits\_qt.py", line 14, in update_gui
int(self.pool_timeout * 1000)
TypeError: arguments did not match any overloaded call:
QCoreApplication.processEvents(QEventLoop.ProcessEventsFlags flags=QEventLoop.AllEvents): argument 1 has unexpected type 'PySide.QtCore.QEventLoop.ProcessEventsFlag'
QCoreApplication.processEvents(QEventLoop.ProcessEventsFlags, int): argument 1 has unexpected type 'PySide.QtCore.QEventLoop.ProcessEventsFlag'
I check the Qt doc the argument should be QEventLoop.ProcessEventsFlags, but I got QeventLoop.ProcessEventsFlag (single not plural) instead.
This example async function will raise StopIteration if called, instead of just returning:
@async
def test():
print "Don't need to yield"
return
yield Task(hello_world)
def hello_world():
print "Hello world"
My initial try at a fix is to subclass Runner and my desired engine to ignore StopIteration.
class CustomRunner(Runner):
def run(self):
try:
return super(CustomRunner, self).run()
except StopIteration:
pass
class CustomEngine(Engine):
def create_runner(self, gen):
return CustomRunner(self, gen)
Would we able to get a pypi update with the kivy version?
For python2.7 support we will need to use a compatibility layer.
http://trollius.readthedocs.io/using.html
trollius uses the same api as asyncio.
The work involves mainly implementing the AbstractEventLoop
https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.AbstractEventLoop
Consider the following:
def bad():
worse()
def worse():
raise RuntimeError("Bad Day")
Currently, if this code gets executed in a Task, we'll lose the traceback, only the last line will show up.
When I ran across this problem with Python Futures in my own code, I came up with a janky solution with a subclassed Executor class, perhaps you can think of something better than this for async_gui, which is awesome btw, thank you.
class CustomExecutor(concurrent.futures.thread.ThreadPoolExecutor):
def submit(self, task, *args, **kwargs):
@functools.wraps(task)
def task_wrapper():
try:
return task(*args, **kwargs)
except Exception as e:
logger.exception("Error executing %r with args %r and kwargs %r" % (task, args, kwargs))
raise
future = super(CustomExecutor, self).submit(task_wrapper)
return future
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.