Skip to content

Commit

Permalink
Setting up CPython repo is now done in the worker app. (GH-34)
Browse files Browse the repository at this point in the history
Instead of in the main app.
  • Loading branch information
Mariatta authored Oct 14, 2017
1 parent dbe0d8e commit b1e1128
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 1 addition & 4 deletions backport/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from gidgethub import routing
from gidgethub import sansio

from . import tasks

from . import backport_pr
from . import delete_branch
from . import status_change
Expand Down Expand Up @@ -47,10 +47,7 @@ async def main(request):


if __name__ == "__main__": # pragma: no cover
id = tasks.setup_cpython_repo.delay()
print(f"Setting up CPython Repo Task: {id}")
app = web.Application()
app['cpython_task_id'] = id
app.router.add_post("/", main)
port = os.environ.get("PORT")
if port is not None:
Expand Down
13 changes: 13 additions & 0 deletions backport/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import os
import subprocess

from celery import bootsteps

from cherry_picker import cherry_picker

from . import util
Expand All @@ -14,6 +16,7 @@

@app.task(rate_limit="1/m")
def setup_cpython_repo():
print("Setting up CPython repository")
if "cpython" not in os.listdir('.'):
subprocess.check_output(
f"git clone https://{os.environ.get('GH_AUTH')}:[email protected]/miss-islington/cpython.git".split())
Expand Down Expand Up @@ -64,3 +67,13 @@ def backport_task(commit_hash, branch, *, issue_number, created_by, merged_by):
```
""")
cp.abort_cherry_pick()


class InitRepoStep(bootsteps.StartStopStep):

def start(self, c):
print("Initialize the repository.")
setup_cpython_repo()


app.steps['worker'].add(InitRepoStep)

0 comments on commit b1e1128

Please sign in to comment.