New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread issues #281

Closed
mpmc opened this Issue Oct 21, 2017 · 10 comments

Comments

Projects
None yet
2 participants
@mpmc
Contributor

mpmc commented Oct 21, 2017

There seems to be some weird issues with thread (on next_release).

self.thread(self.device_info_thread, None, **kwargs)
result:
TypeError: thread() got an unexpected keyword argument 'addr'.

Seems thread "eats" unpacked variables?

calling self.thread(self.device_info_thread, kwargs)
result:

Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
TypeError: device_info_thread() takes 1 positional argument but 2 were given

The only positional argument is self.. def device_info_thread(self, **kwargs): thread always passes kwargs as args, an example.

self.thread(self.device_info_thread, None, kwargs)
def device_info_thread(self, *args, **kwargs):
        print(args) <-- this prints all args and kwargs!
        print(kwargs)

While testing this I crashed my machine (hard lock) & made Python die three times 🤣.

@jarvisteach jarvisteach added the bug label Oct 22, 2017

jarvisteach added a commit that referenced this issue Oct 22, 2017

@jarvisteach

This comment has been minimized.

Owner

jarvisteach commented Oct 23, 2017

@mpmc - I've updated the functions so that args are passed better, let me know if it helps...

@mpmc

This comment has been minimized.

Contributor

mpmc commented Oct 24, 2017

Sadly it doesn't. I now get..

xception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python3.5/tkinter/__init__.py", line 1553, in __call__
    return self.func(*args)
  File "/usr/lib/python3.5/tkinter/__init__.py", line 599, in callit
    func(*args)
  File "/home/mark/.local/lib/python3.5/site-packages/appJar/appjar.py", line 1999, in thread
    t = Thread(target=func, *args, **kwargs)
  File "/usr/lib/python3.5/threading.py", line 778, in __init__
    assert group is None, "group argument must be None for now"
AssertionError: group argument must be None for now

Possible fix here.

jarvisteach added a commit that referenced this issue Oct 24, 2017

Update to threads
#120 & #281 - the parameters are strange, I think it’s working now…
@jarvisteach

This comment has been minimized.

Owner

jarvisteach commented Oct 24, 2017

third time lucky?

@mpmc

This comment has been minimized.

Contributor

mpmc commented Oct 24, 2017

Yep, self.thread(self.device_info_thread, None, **kwargs) works, thanks :)

@mpmc mpmc closed this Oct 24, 2017

@mpmc

This comment has been minimized.

Contributor

mpmc commented Oct 24, 2017

Discovered another kwargs issue 😞

self.after(100, self.thread, self.device_info_thread, **kwargs)

with error..

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python3.5/tkinter/__init__.py", line 1553, in __call__
    return self.func(*args)
  File "/home/mark/.local/lib/python3.5/site-packages/appJar/appjar.py", line 3151, in <lambda>
    return lambda: funcName(param)
  File "gui2.py", line 211, in connect_btn
    self.device_connect(**values)
  File "gui2.py", line 250, in device_connect
    self.after(100, self.thread, self.device_info_thread, **kwargs)
TypeError: after() got an unexpected keyword argument 'addr'

@mpmc mpmc reopened this Oct 24, 2017

@jarvisteach

This comment has been minimized.

Owner

jarvisteach commented Oct 24, 2017

Phew - I think this one isn't my fault :)

tkinter's after function doesn;t support **kwargs : http://effbot.org/tkinterbook/widget.htm

@jarvisteach jarvisteach added this to the 0.90 milestone Oct 24, 2017

@mpmc

This comment has been minimized.

Contributor

mpmc commented Oct 24, 2017

Phew - I think this one isn't my fault :)

It's not too much of an problem but I thought you should be aware so you can make a note of it in the "after" doc :).

I'll just call the methods directly instead of using after, my initial intention was to add a small delay so the operation could be cancelled.

@jarvisteach

This comment has been minimized.

Owner

jarvisteach commented Oct 24, 2017

The docs only mention *args - so you can still pass arguments, just not named ones...

http://appjar.info/pythonLoopsAndSleeps/#sleeps

@mpmc

This comment has been minimized.

Contributor

mpmc commented Oct 24, 2017

The docs only mention *args - so you can still pass arguments, just not named ones...

Yep, I know, but most people whenever they see *args, assume they can use **kwargs as well 👅

@jarvisteach

This comment has been minimized.

Owner

jarvisteach commented Oct 24, 2017

Fair point!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment