Code Monkey home page Code Monkey logo

asyncio-tkinter's People

Contributors

alancristhian avatar ramalho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asyncio-tkinter's Issues

'Future' object has no attribute '_copy_state'

In either tkapp.py or tkapp2.py, clicking the "Count Words" or "Call with futures" button respectively (both of which use futures) gives the following error in Python 3.5:

exception calling callback for <Future at 0x10e9242b0 state=finished returned list>
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/concurrent/futures/_base.py", line 297, in _invoke_callbacks
    callback(self)
  File ".../asyncio-tkinter/guievents.py", line 43, in <lambda>
    self.call_soon_threadsafe(new_future._copy_state, future))
AttributeError: 'Future' object has no attribute '_copy_state'

Running other async libs with asyncio-tkinter

Hallo,

I just started this project: https://github.com/duk3luk3/faflauncher

Where I'm trying to use asyncio-tkinter and also aiohttp.

With the code as it is in the repo currently:

import tkinter as tk
from tkevents import TkEventLoop
import asyncio

import updater

class Application(tk.Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.pack()
        self.create_widgets()
        #asyncio.async(self.launch())
        #self.do_github()
        #asyncio.get_event_loop().run_until_complete(self.do_github())

    ...

    def launch(self, loop):
        f = asyncio.ensure_future(updater.fetch_tags('FAForever', 'client'), loop=loop)
        f.add_done_callback(app.set_github)

    def set_github(self, fut):
        tag, zipball_url = fut.result()

        self.label["text"] = "{} => {}".format(tag, zipball_url)

root = tk.Tk()
app = Application(master=root)
#app.mainloop()

loop = TkEventLoop(app)
app.launch(loop)
loop.mainloop()

I get this error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib64/python3.6/tkinter/__init__.py", line 1699, in __call__
    return self.func(*args)
  File "/usr/lib64/python3.6/tkinter/__init__.py", line 745, in callit
    func(*args)
  File "src/tkevents.py", line 46, in <lambda>
    lambda cb, a : cb(*a),
  File "src/__main__.py", line 44, in set_github
    tag, zipball_url = fut.result()
  File "src/updater.py", line 20, in fetch_tags
    response = await fetch(session, url)
  File "src/updater.py", line 13, in fetch
    async with session.get(url) as response:
  File "/home/erlacher/git/faf/launcher/.venv/lib/python3.6/site-packages/aiohttp/client.py", line 603, in __aenter__
    self._resp = yield from self._coro
  File "/home/erlacher/git/faf/launcher/.venv/lib/python3.6/site-packages/aiohttp/client.py", line 231, in _request
    conn = yield from self._connector.connect(req)
  File "/home/erlacher/git/faf/launcher/.venv/lib/python3.6/site-packages/aiohttp/connector.py", line 378, in connect
    proto = yield from self._create_connection(req)
  File "/home/erlacher/git/faf/launcher/.venv/lib/python3.6/site-packages/aiohttp/connector.py", line 687, in _create_connection
    _, proto = yield from self._create_direct_connection(req)
  File "/home/erlacher/git/faf/launcher/.venv/lib/python3.6/site-packages/aiohttp/connector.py", line 698, in _create_direct_connection
    hosts = yield from self._resolve_host(req.url.raw_host, req.port)
  File "/home/erlacher/git/faf/launcher/.venv/lib/python3.6/site-packages/aiohttp/connector.py", line 669, in _resolve_host
    self._resolver.resolve(host, port, family=self._family)
  File "/home/erlacher/git/faf/launcher/.venv/lib/python3.6/site-packages/aiohttp/resolver.py", line 31, in resolve
    host, port, type=socket.SOCK_STREAM, family=family)
RuntimeError: Task <Task pending coro=<fetch_tags() running at src/updater.py:20> cb=[Application.set_github()]> got Future <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/lib64/python3.6/asyncio/futures.py:408]> attached to a different loop

This seems to be a somewhat common problem when trying to merge two async projects.

Can you give me any insights into why that is and how to fix it?

SyntaxError

Which file is the one to start with? I tried to start tkapp.py or tkapp2.py.
In both cases I get:

d:\daten\python\asyncio-tkinter-master>python3 tkapp2.py
  File "tkapp2.py", line 11
    def async(it, *args):
            ^
SyntaxError: invalid syntax

I am using python 3.7.0 on Windows 10.

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.