10
10
from codegen .runner .sandbox .runner import SandboxRunner
11
11
from codegen .shared .exceptions .compilation import UserCodeException
12
12
from codegen .shared .logging .get_logger import get_logger
13
- from codegen .shared .performance .stopwatch_utils import stopwatch
14
13
15
14
logger = get_logger (__name__ )
16
15
@@ -39,7 +38,6 @@ async def process_request(self, request: TRequest, call_next: RequestResponseEnd
39
38
logger .info (f"> (CodemodRunMiddleware) Request: { request .url .path } " )
40
39
self .runner .codebase .viz .clear_graphviz_data ()
41
40
response = await call_next (request )
42
- background_tasks .add_task (self .cleanup_after_codemod , is_exception = False )
43
41
response .background = background_tasks
44
42
return response
45
43
@@ -52,21 +50,5 @@ async def process_request(self, request: TRequest, call_next: RequestResponseEnd
52
50
message = f"Unexpected error for { request .url .path } "
53
51
logger .exception (message )
54
52
res = JSONResponse (status_code = HTTPStatus .INTERNAL_SERVER_ERROR , content = {"detail" : message , "error" : str (e ), "traceback" : traceback .format_exc ()})
55
- background_tasks .add_task (self .cleanup_after_codemod , is_exception = True )
56
53
res .background = background_tasks
57
54
return res
58
-
59
- async def cleanup_after_codemod (self , is_exception : bool = False ):
60
- if is_exception :
61
- # TODO: instead of committing transactions, we should just rollback
62
- logger .info ("Committing pending transactions due to exception" )
63
- self .runner .codebase .ctx .commit_transactions (sync_graph = False )
64
- await self .reset_runner ()
65
-
66
- @stopwatch
67
- async def reset_runner (self ):
68
- logger .info ("=====[ reset_runner ]=====" )
69
- logger .info (f"Syncing runner to commit: { self .runner .commit } ..." )
70
- self .runner .codebase .checkout (commit = self .runner .commit )
71
- self .runner .codebase .clean_repo ()
72
- self .runner .codebase .checkout (branch = self .runner .codebase .default_branch , create_if_missing = True )
0 commit comments