@@ -298,27 +298,28 @@ async def get_or_create(
298
298
rqst .set_json (params )
299
299
async with rqst .fetch () as resp :
300
300
data = await resp .json ()
301
- with tqdm (total = 100 , unit = '%' ) as pbar :
302
- task_id = data ['background_task' ]
303
- bgtask = resp .session .BackgroundTask (task_id )
304
- async with bgtask .listen_events () as response :
305
- async for ev in response :
306
- progress = json .loads (ev .data )
307
- if ev .event == 'bgtask_updated' :
308
- current = progress ['current_progress' ]
309
- total = progress ['total_progress' ]
310
- if total == 0 :
311
- total = 1e-2
312
- pbar .n = round (current / total * 100 , 2 )
313
- pbar .update (0 )
314
- pbar .refresh ()
315
- elif ev .event == 'bgtask_done' :
316
- pbar .n = 100.0
317
- pbar .update (0 )
318
- pbar .refresh ()
319
- pbar .clear ()
320
- async with rqst .fetch () as resp :
321
- data = await resp .json ()
301
+ if 'background_task' in data :
302
+ with tqdm (total = 100 , unit = '%' ) as pbar :
303
+ task_id = data ['background_task' ]
304
+ bgtask = resp .session .BackgroundTask (task_id )
305
+ async with bgtask .listen_events () as response :
306
+ async for ev in response :
307
+ progress = json .loads (ev .data )
308
+ if ev .event == 'bgtask_updated' :
309
+ current = progress ['current_progress' ]
310
+ total = progress ['total_progress' ]
311
+ if total == 0 :
312
+ total = 1e-2
313
+ pbar .n = round (current / total * 100 , 2 )
314
+ pbar .update (0 )
315
+ pbar .refresh ()
316
+ elif ev .event == 'bgtask_done' :
317
+ pbar .n = 100.0
318
+ pbar .update (0 )
319
+ pbar .refresh ()
320
+ pbar .clear ()
321
+ async with rqst .fetch () as resp :
322
+ data = await resp .json ()
322
323
o = cls (name , owner_access_key ) # type: ignore
323
324
if api_session .get ().api_version [0 ] >= 5 :
324
325
o .id = UUID (data ['sessionId' ])
0 commit comments