Skip to content
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

Udp_server spawns 60 threads... #16

Open
balena opened this issue Dec 16, 2015 · 0 comments
Open

Udp_server spawns 60 threads... #16

balena opened this issue Dec 16, 2015 · 0 comments

Comments

@balena
Copy link

balena commented Dec 16, 2015

By default the nworkers attribute of Udp_server_opts is initialized with the value 30, from variable _DEFAULT_NWORKERS. It comes that during the Udp_server initialization, it spawns 30 senders and 30 receivers, each of them represented by a respective Thread (started in the constructor).

The only reason I could find for spawning these threads is due the synchronous name resolution performed by 'socket.getaddrinfo'.

A more modern approach is to delegate the name resolution to an appropriate asynchronous resolver, such as the one available on tornado, or on pycares. Of course, adequate profiling is desirable to demonstrate any optimization gain, but this latter approach would use less memory and would cause less overhead when processing bursts of incoming messages. Anyway, it will make the code far simpler and easier to maintain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant