Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

fix: reset UAID if too many messages are pending #728

Merged
merged 1 commit into from
Nov 8, 2016
Merged

Conversation

jrconlin
Copy link
Member

@jrconlin jrconlin commented Nov 8, 2016

closes #473

@codecov-io
Copy link

codecov-io commented Nov 8, 2016

Current coverage is 100% (diff: 100%)

Merging #728 into master will not change coverage

@@           master    #728   diff @@
=====================================
  Files          48      48          
  Lines       10146   10184    +38   
  Methods         0       0          
  Messages        0       0          
  Branches        0       0          
=====================================
+ Hits        10146   10184    +38   
  Misses          0       0          
  Partials        0       0          

Powered by Codecov. Last update 04756c4...461a866

"""errBack for handling excessive messages per UAID"""
fail.trap(MessageOverloadException)
self.ap_settings.router.drop_user(self.ps.uaid)
self.send_close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

send_close doesn't exist

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it's sendClose. Odd that it didn't get flagged in the tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should make websocket tests' tearDown fail the test if a log.failure is called and wasn't marked as being expected

since websocket ends up eating exceptions and just closing the connection in some cases

@@ -145,6 +145,9 @@ def add_shared_args(parser):
env_var="HUMAN_LOGS")
parser.add_argument('--no_aws', help="Skip AWS meta information checks",
action="store_true", default=False)
parser.add_argument('--msg_limit', help="Max limit for messages per uaid "
"before reset", type=int, default="1000",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default at 100?

@@ -986,6 +1000,9 @@ def finish_webpush_notifications(self, result):
self.ps.updates_sent[str(notif.channel_id)].append(notif)
msg = notif.websocket_format()
messages_sent = True
update_cnt += 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This count should be cleared after all the messages out of storage have been processed to ensure any later requests to check storage get a fresh starting point.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine doing that, but wouldn't the arg fall out of scope pretty fast once we're out of this function? (I note that pycharm greys out the var as unused once we're past the loop.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry, this won't work. We only fetch 10 at a time, so the max number this will ever be here is 10.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! Ok, that makes more sense then. I'll move the counter bit further out.

@jrconlin jrconlin force-pushed the bug/473 branch 2 times, most recently from 875f0e1 to 5e15742 Compare November 8, 2016 22:43
def error_message_overload(self, fail):
"""errBack for handling excessive messages per UAID"""
fail.trap(MessageOverloadException)
self.ap_settings.router.drop_user(self.ps.uaid)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be run in a thread?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, looks like it should be in a force_retry to make sure it runs even if a client drops.

Copy link
Member

@bbangert bbangert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+

@jrconlin jrconlin merged commit 18cb974 into master Nov 8, 2016
@pjenvey pjenvey deleted the bug/473 branch November 10, 2016 01:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reset UAID when too many messages are stored
4 participants