Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python2
from __future__ import print_function
import gc
import time
import threading
from more_executors import Executors
def dump_threads():
print("------------- threads ----------------")
@rohanpm
rohanpm / remove-duplicate-test
Last active March 27, 2019 15:31
Improving remove_unit_duplicate_nevra performance
#!/usr/bin/env python
"""Benchmark script showing difference between current remove_unit_duplicate_nevra
and implementation with adjusted queries.
Logs for running this over real data:
2019-03-11 03:52:15,745 Testing queries for repo: rhel-7-server-release-e2e-test-1-rpms__x86_64
2019-03-11 03:52:15,752 Start improved for rhel-7-server-release-e2e-test-1-rpms__x86_64 (1584 units)
2019-03-11 03:52:15,755 End improved for rhel-7-server-release-e2e-test-1-rpms__x86_64
2019-03-11 03:52:15,755 Start original for rhel-7-server-release-e2e-test-1-rpms__x86_64 (1584 units)
@rohanpm
rohanpm / revoketest.py
Created March 22, 2019 02:14
Celery qpid revoke bug
"""
Reproducer for celery task revoke bugs.
Save this file as something like "revoketest.py" and run it to execute
testcases.
Includes three subcommands:
worker:
Use this to run the celery worker
From bfb8b1c967586346d1d67433b3631bc473eb04c3 Mon Sep 17 00:00:00 2001
From: Rohan McGovern <rmcgover@redhat.com>
Date: Fri, 30 Aug 2019 11:03:26 +0800
Subject: [PATCH] Let callers pass datetime objects when searching on datetime
fields
---
pubtools/pulplib/_impl/client/search.py | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
@rohanpm
rohanpm / 0001-Add-Django-1.11-configurations-to-CI.patch
Created February 13, 2020 03:40
[PATCH] Add Django 1.11 configurations to CI
From e3d4e8b898076400ec6bd27f7fddd9ccb0d1c6df Mon Sep 17 00:00:00 2001
From: Rohan McGovern <rmcgover@redhat.com>
Date: Thu, 13 Feb 2020 13:39:33 +1000
Subject: [PATCH] Add Django 1.11 configurations to CI
---
constraints-django111.txt | 1 +
tox.ini | 5 +++--
2 files changed, 4 insertions(+), 2 deletions(-)
create mode 100644 constraints-django111.txt
@rohanpm
rohanpm / TESTLOG.txt
Created February 13, 2020 03:44
kobo tests with Django 1.11
GLOB sdist-make: /home/rmcgover/src/kobo/setup.py
py37-django111 inst-nodeps: /home/rmcgover/src/kobo/.tox/.tmp/package/1/kobo-0.11.0.zip
py37-django111 installed: attrs==19.3.0,certifi==2019.11.28,cffi==1.14.0,chardet==3.0.4,cryptography==2.8,Django==1.11.28,idna==2.8,importlib-metadata==1.5.0,kobo==0.10.0,koji==1.20.0,linecache2==1.0.0,mock==2.0.0,more-itertools==8.2.0,packaging==20.1,pbr==5.4.4,pluggy==0.13.1,py==1.8.1,pycparser==2.19,pykerberos==1.2.1,pyOpenSSL==19.1.0,pyparsing==2.4.6,pytest==5.3.5,pytest-env==0.6.2,python-dateutil==2.8.1,pytz==2019.3,requests==2.22.0,requests-kerberos==0.12.0,six==1.14.0,traceback2==1.4.0,unittest2==1.1.0,urllib3==1.25.8,wcwidth==0.1.8,zipp==2.2.0
py37-django111 run-test-pre: PYTHONHASHSEED='4123058499'
py37-django111 run-test: commands[0] | make test
py.test
============================= test session starts ==============================
platform linux -- Python 3.7.5, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
cachedir: .tox/py37-django111/.pytest_cache
rootdir: /home/rmcg
#!/usr/bin/env python3
import logging
from kobo.client import HubProxy
from kobo.conf import PyConfigParser
logging.basicConfig(level=logging.DEBUG)
URL = 'https://pub.devel.redhat.com/pub/xmlrpc'
# Tested over /mnt/redhat/rel-eng/OpenShiftEnterprise/4.4/images/cdn
# with realistic environment
result-both-sums.txt:real 0m13.294s
result-both-sums.txt:real 0m15.049s
result-both-sums.txt:real 0m14.133s
result-both-sums.txt:real 0m13.102s
result-both-sums.txt:real 0m14.525s
result-both-sums.txt:real 0m13.979s
result-both-sums.txt:real 0m15.156s
result-both-sums.txt:real 0m15.098s
@rohanpm
rohanpm / count1000.js
Created November 12, 2020 21:34
Comparing count vs find for query with no results
// 2000 iterations of a query counting on 1000 IDs and not finding anything
for (var i = 0; i < 2000; i++) {
print(db.repo_content_units.count({"_id": {"$in": ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '100', '101', '102', '103', '104', '105', '106', '107', '108', '109', '110', '111', '112', '113', '114', '115', '116', '117', '118', '119', '120', '121', '122', '123', '124', '125', '126', '127', '128', '129', '130', '131', '132', '133', '134', '135', '136', '137', '138', '
@rohanpm
rohanpm / force-retry.patch
Created September 22, 2023 05:03
Force exodus-gw to retry every S3 request at least three times (even if it succeeded)
diff --git a/exodus_gw/aws/client.py b/exodus_gw/aws/client.py
index 5cbf1f5..beb52f5 100644
--- a/exodus_gw/aws/client.py
+++ b/exodus_gw/aws/client.py
@@ -1,3 +1,4 @@
+import logging
import os
import aioboto3
@@ -38,12 +39,21 @@ class S3ClientWrapper: