async for plugin methods

19 views
Skip to first unread message

Андрей [ND]

unread,
Jan 9, 2020, 4:04:28 PM1/9/20
to dis...@nose2.io
Hello.

I've done my own nose2 plugin, which has startTestRun, stopTestRun, startTest and startTest methods. Each method sends some POST request to my server. Everything is ok, when I'm using any UI tests (selenium), but unit tests are slow because of network latency and synchronous plugins methods. 
Currently I'm trying to use aiohttp (with async await) for previously mentioned methods, but seems that it's not working... Maybe you can provide any help, maybe some basic example or give some advice? 

Thanks!

--
Regards,
Andrew.

Stephen Rosen

unread,
Apr 2, 2020, 3:35:23 PM4/2/20
to nose2 discuss, and....@gmail.com
Hi Andrew,

Somehow, this mail never made it to my inbox -- I'll double-check the group settings to try to see what went wrong, but I only saw it when I checked directly on the group. Sorry about that.

While I don't have any examples, one thought I have is that you could setup your own mechanism for making the network IO part of your plugin async.
For example, you could have the plugin start a background process (or thread) during startTestRun which is responsible for relaying messages over the network (async), send messages to it during other methods, and then ensure that the background process has finished its sending and tears down in a step like afterTestRun.

If you want to try to give it a go, I'd be happy to help review and put together a simplified example of a plugin like this in the docs. For example, we could write a version which does background work and writes messages to a file (so that we don't need network resources to show that it works). I probably don't have time to write something completely new any time soon, but if you're interested, a PR on the GitHub repo would be a great starting point.

Best (and sorry about the delay in my reply),
-Stephen
Reply all
Reply to author
Forward
0 new messages