File tree 2 files changed +24
-2
lines changed
2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change
1
+ import logging
2
+
3
+ def cleanup ():
4
+ logging .info ("Executing table cleanup function" )
Original file line number Diff line number Diff line change
1
+ import logging
1
2
import azure .functions as func
2
3
import spotbot as sb
4
+ import cleanup
3
5
4
6
app = func .FunctionApp (http_auth_level = func .AuthLevel .FUNCTION )
5
7
6
8
@app .route (route = "spotbot" , methods = [func .HttpMethod .POST ])
7
9
def spotbot (req : func .HttpRequest ) -> func .HttpResponse :
8
- sb .run (req )
9
- return func .HttpResponse (status_code = 202 )
10
+ try :
11
+ sb .run (req )
12
+ except Exception as _excpt :
13
+ logging .error (f"Exception occurred: { _excpt } " )
14
+ return func .HttpResponse (body = f"Exception occurred: { _excpt } " , status_code = 500 )
15
+ else :
16
+ return func .HttpResponse (status_code = 202 )
17
+
18
+ @app .function_name (name = "tablecleanup" )
19
+ @app .schedule (schedule = "0 8 * * *" ,
20
+ arg_name = "tablecleanup" ,
21
+ run_on_startup = False )
22
+ def table_cleanup (timer : func .TimerRequest ) -> None :
23
+ cleanup .cleanup ()
24
+
25
+ @app .route (route = "manualcleanup" , methods = [func .HttpMethod .POST ])
26
+ def manual_cleanup (req : func .HttpRequest ) -> func .HttpResponse :
27
+ cleanup .cleanup ()
You can’t perform that action at this time.
0 commit comments