Skip to content

Commit b1e1128

Browse files
authored
Setting up CPython repo is now done in the worker app. (GH-34)
Instead of in the main app.
1 parent dbe0d8e commit b1e1128

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

backport/__main__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from gidgethub import routing
1212
from gidgethub import sansio
1313

14-
from . import tasks
14+
1515
from . import backport_pr
1616
from . import delete_branch
1717
from . import status_change
@@ -47,10 +47,7 @@ async def main(request):
4747

4848

4949
if __name__ == "__main__": # pragma: no cover
50-
id = tasks.setup_cpython_repo.delay()
51-
print(f"Setting up CPython Repo Task: {id}")
5250
app = web.Application()
53-
app['cpython_task_id'] = id
5451
app.router.add_post("/", main)
5552
port = os.environ.get("PORT")
5653
if port is not None:

backport/tasks.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import os
33
import subprocess
44

5+
from celery import bootsteps
6+
57
from cherry_picker import cherry_picker
68

79
from . import util
@@ -14,6 +16,7 @@
1416

1517
@app.task(rate_limit="1/m")
1618
def setup_cpython_repo():
19+
print("Setting up CPython repository")
1720
if "cpython" not in os.listdir('.'):
1821
subprocess.check_output(
1922
f"git clone https://{os.environ.get('GH_AUTH')}:[email protected]/miss-islington/cpython.git".split())
@@ -64,3 +67,13 @@ def backport_task(commit_hash, branch, *, issue_number, created_by, merged_by):
6467
```
6568
""")
6669
cp.abort_cherry_pick()
70+
71+
72+
class InitRepoStep(bootsteps.StartStopStep):
73+
74+
def start(self, c):
75+
print("Initialize the repository.")
76+
setup_cpython_repo()
77+
78+
79+
app.steps['worker'].add(InitRepoStep)

0 commit comments

Comments
 (0)