Problem with uasyncio running picoweb - TypeError: function takes 2 positional arguments but 3 were given

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
pfalcon
Posts: 1154
Joined: Fri Feb 28, 2014 2:05 pm

Re: Problem with uasyncio running picoweb - TypeError: function takes 2 positional arguments but 3 were given

Post by pfalcon » Sat Feb 02, 2019 10:26 pm

eltomek wrote:
Sat Feb 02, 2019 9:32 pm
File "uasyncio/__init__.py", line 60, in remove_writer
TypeError: function takes 2 positional arguments but 3 were given
MicroPython v1.10-188-gf1644bca9 on 2019-02-02; ESP module with ESP8266
Yes, that looks like a bug. Thanks for the report and detailed info, please run "git pull --rebase" and try the latest version.
Type "help()" for more information.

Anyone could try it to confirm it works? What's even more, when running app with Debug=1 I additionally get:
ImportError: no module named 'logging'
And this unfortunately lacks the detailed traceback info like above, so it's hard to tell what may be involved. So, let me just say "cannot reproduce".
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

eltomek
Posts: 11
Joined: Sat Feb 02, 2019 8:32 am

Re: Problem with uasyncio running picoweb - TypeError: function takes 2 positional arguments but 3 were given

Post by eltomek » Sat Feb 02, 2019 11:05 pm

Thanks @pfalcon!
I did the update and it works ok now. I can see you have pushed quite a lot of commits today, thanks!

$ git pull --rebase
remote: Enumerating objects: 196, done.
remote: Counting objects: 100% (196/196), done.
remote: Compressing objects: 100% (95/95), done.
remote: Total 196 (delta 101), reused 196 (delta 101), pack-reused 0
Receiving objects: 100% (196/196), 35.22 KiB | 655.00 KiB/s, done.
Resolving deltas: 100% (101/101), completed with 3 local objects.
From https://github.com/pfalcon/pycopy
+ f1644bca9...ec2bf2fe0 pfalcon -> origin/pfalcon (forced update)
First, rewinding head to replay your work on top of it...

However, I need to turn debugging off (app.run(debug=-1)), otherwise I get:
PYB: soft reboot
scandone
Connection successful
('192.168.0.87', '255.255.255.0', '192.168.0.1', '62.179.1.62')
Traceback (most recent call last):
File "main.py", line 67, in <module>
File "picoweb/__init__.py", line 283, in run
ImportError: no module named 'logging'
MicroPython v1.10-189-gec2bf2fe0 on 2019-02-02; ESP module with ESP8266
Type "help()" for more information.

Looks like despite importing ulogging as logging, the picoweb still needs logging library. I am running a bit updated example https://github.com/pfalcon/picoweb/blob ... _webapp.py so that you may not match the line numbers.
File "main.py", line 67, in <module>
in my file is
app.run(debug=1, host=station.ifconfig()[0])

The doc says:
"The default value for debug parameter is 0 however, in which case picoweb will use ulogging module (on which your application needs to depend, again)."
However, with app.run(debug=0) or app.run() micropython throws an ImportError: no module named 'logging' too (despite importin ulogging as logging). Is that ok?

Anyway, the web server finally works now, thank you for the great project and for support!

pfalcon
Posts: 1154
Joined: Fri Feb 28, 2014 2:05 pm

Re: Problem with uasyncio running picoweb - TypeError: function takes 2 positional arguments but 3 were given

Post by pfalcon » Sun Feb 03, 2019 6:52 am

eltomek wrote:
Sat Feb 02, 2019 11:05 pm
Thanks @pfalcon!
I did the update and it works ok now. I can see you have pushed quite a lot of commits today, thanks!
My fork is rebased on top of mainline regularly (i.e. contains all that mainline contains), and that's how rebases look - a lot of metadata seems to be updated, but the content is the same.
[]
Traceback (most recent call last):
File "main.py", line 67, in <module>
File "picoweb/__init__.py", line 283, in run
ImportError: no module named 'logging'
MicroPython v1.10-189-gec2bf2fe0 on 2019-02-02; ESP module with ESP8266
Type "help()" for more information.
D'oh, that's what good testing and reports mean. Turns out, the 1.5.2 release of picoweb with the conversion to ulogging was sitting in my tree, not pushed to PyPI. Dunno how it happened - whether I was without the Internet at that time or PyPI itself was down. And I test mostly using MicroPython unix port these days, running it either against git tree, or against full micropython-lib, so that was missed, yeah.

Anyway, released picoweb 1.5.2 now, please give it a try, everything is intended to work out of the box of course.

Btw, uasyncio and picoweb have their own dedicated threads, if you spot any further issues, feel free to post there. I noticed this thread by a chance.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

davlefou
Posts: 3
Joined: Mon Jan 28, 2019 3:15 pm

Re: Problem with uasyncio running picoweb - TypeError: function takes 2 positional arguments but 3 were given

Post by davlefou » Sun Feb 03, 2019 4:06 pm

Hi, to solved for ulogging you can do that in __init__.py of picoweb:
def run(self, host="127.0.0.1", port=8081, debug=-1, lazy_init=False, log=None)

et for uasyncia in __init__.py in "def remove_writer(self, sock):"
udpate that self.poller.unregister(sock, False)
bay:
try:
self.poller.unregister(sock, False)
except:
print('Echec unregister')

It not well but it work.

davlefou
Posts: 3
Joined: Mon Jan 28, 2019 3:15 pm

Re: Problem with uasyncio running picoweb - TypeError: function takes 2 positional arguments but 3 were given

Post by davlefou » Mon Feb 04, 2019 2:46 pm

And it is the same problem with esp32 card.

eltomek
Posts: 11
Joined: Sat Feb 02, 2019 8:32 am

Re: Problem with uasyncio running picoweb - TypeError: function takes 2 positional arguments but 3 were given

Post by eltomek » Tue Feb 12, 2019 9:57 pm

pfalcon wrote:
Sun Feb 03, 2019 6:52 am
Anyway, released picoweb 1.5.2 now, please give it a try, everything is intended to work out of the box of course
Worked as a charm, many thanks!

DMT_ZA
Posts: 1
Joined: Sun Mar 10, 2019 11:11 am

Re: Problem with uasyncio running picoweb - TypeError: function takes 2 positional arguments but 3 were given

Post by DMT_ZA » Sat Apr 13, 2019 9:59 am

[quote=pythoncoder post_id=33771 time=1549099030 user_id=265]
If you are running the @pfalcon "Pycopy" fork you need to use his fork of [b]uasyncio[/b] which may be installed using [b]upip[/b] or from [url=https://github.com/pfalcon/micropython-lib.git]here[/url].
[/quote]

I am somewhat confused between the "official" Micropython and the Pycopy fork. To get clarity, are you saying that if I have an official build and I use upip to download packages, it will download from the fork github.com/pfalcon/micropython-lib and not from the official github.com/micropython/micropython-lib ? If so, this strategy seems a bit odd?

User avatar
pythoncoder
Posts: 3401
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Installing libraries

Post by pythoncoder » Sun Apr 14, 2019 10:05 am

The term "strategy" is something of a misnomer. For an explanation and solutions please see this doc.
Peter Hinch

Post Reply