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

Ratelimit notices #18

Closed
jaraco opened this issue Nov 20, 2015 · 5 comments
Closed

Ratelimit notices #18

jaraco opened this issue Nov 20, 2015 · 5 comments

Comments

@jaraco
Copy link
Owner

jaraco commented Nov 20, 2015

Given certain situations, it's possible for someone to force a bot to exit if too many notices are buffered.

I'm sure I could rate limit in my code, but a forced rate limit in the lib might also be warranted.


@jaraco
Copy link
Owner Author

jaraco commented Nov 20, 2015

I've put together a draft implementation that would allow one to set a rate limit on a connection in 95d201adc509. One would simply call connection.set_rate_limit with a number (messages per second), and it would install a throttler on the send_raw method.

Let me know what you think, and if that interface would be suitable.


Original comment by: Jason R. Coombs

@jaraco
Copy link
Owner Author

jaraco commented Nov 20, 2015

When trying to run it, hit a few snags - not sure if it's me. (not a python guy yet).

client.py - line 967 : should it be .count() not .Count()
client.py - line 971 : self.start isn't a function (I think)

Finally, what I can't figure out is this traceback:

File "./libs/irc/bot.py", line 259, in start
self._connect()
File "./libs/irc/bot.py", line 115, in _connect
*_self.__connect_params)
File "./libs/irc/client.py", line 1173, in connect
self.connection.connect(_args, *_kwargs)
File "./libs/irc/functools.py", line 37, in wrapper
return method(self, *args, *_kwargs)
File "./libs/irc/client.py", line 494, in connect
self.nick(self.nickname)
File "./libs/irc/client.py", line 816, in nick
self.send_raw("NICK " + newnick)
File "./libs/irc/client.py", line 974, in call
return self.func()
TypeError: send_raw() takes exactly 2 arguments (1 given)


Original comment by: Jason Kendall

@jaraco jaraco closed this as completed Nov 20, 2015
@jaraco
Copy link
Owner Author

jaraco commented Nov 20, 2015

Thanks for the help in troubleshooting and for the pull request. I've accepted the pull request and taken the opportunity to also add a couple of tests to exercise the Throttler class (something I would normally have done early).

I've released 8.2 with this feature. Please let me know if you encounter any other issues.


Original comment by: Jason R. Coombs

@jaraco
Copy link
Owner Author

jaraco commented Nov 20, 2015

Fixed and released in 8.2


Original comment by: Jason R. Coombs

@jaraco
Copy link
Owner Author

jaraco commented Nov 20, 2015

Thanks Jason. No way I would have thought of that method. Good learning for me as well.


Original comment by: Jason Kendall

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