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

Use microseconds in addition to PID. Use the sorted file list. #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mdcollins05
Copy link

Also, we try really hard to send the events in the right order. The latest code worked 6 out of 6 tries with 1/10th of a second between calls to pagerduty.py, which were run in the background.


sorted_file_names = sorted(pd_file_names, key=file_timestamp)
return pd_file_names
sorted_file_names = sorted(pd_file_names, key=file_timestamp, reverse=True)
Copy link

Choose a reason for hiding this comment

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

Oops - have we been sorting this wrong?! Can you show some example file names & sort results here from a python console run?

Copy link
Author

Choose a reason for hiding this comment

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

When I was testing without reverse it seemed to always send them in the wrong order. I'll do some more concrete tests via the Python console.

Copy link

Choose a reason for hiding this comment

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

If you enqueue a few things & then either run this code by hand or run it with print/log statements, we should be able to see how the sorting goes. :)

Copy link

Choose a reason for hiding this comment

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

Q: were the tests for seconds version of the code + sends in the same second?

Copy link
Author

Choose a reason for hiding this comment

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

I think due to the queued files and because I wasn't using the cronjob to flush the queue, I ended up sending the files wrong in the wrong order by name but they looked right when viewing the trigger/resolve API calls. I'll fix the ordering and make the few other changes.

Using time.time()'s already available microseconds
@mdcollins05
Copy link
Author

Updated with the suggestions from before. It looks like we weren't using the correct variable after sorting the file list.

@@ -142,7 +142,7 @@ def file_timestamp(file_name):
return int(re.search('pd_(\d+)_', file_name).group(1))

sorted_file_names = sorted(pd_file_names, key=file_timestamp)
return pd_file_names
return sorted_file_names
Copy link

Choose a reason for hiding this comment

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

:P

@divtxt
Copy link

divtxt commented Jul 28, 2015

Looks good!

@divtxt
Copy link

divtxt commented Jul 28, 2015

(title of the PR a bit misleading now, but meh :)

@mdcollins05 mdcollins05 changed the title Use microseconds instead of PID Use microseconds in addition to PID. Use the sorted file list. Jul 28, 2015
@mdcollins05
Copy link
Author

Fixed!

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

Successfully merging this pull request may close these issues.

2 participants