miyuki2026 commited on
Commit
5f290ae
·
1 Parent(s): 4ed3af7
main.py CHANGED
@@ -115,10 +115,8 @@ def main():
115
  key = porter_task_file.stem
116
  value = environment.get(key=key, default=False, dtype=bool)
117
  logger.info(f"{key}: {value}")
118
-
119
  if value is True:
120
  task_manager.add_tasks_by_task_file(tasks_file=porter_task_file.as_posix())
121
-
122
  task_thread = threading.Thread(
123
  target=async_thread_wrapper,
124
  args=(task_manager.run(),),
 
115
  key = porter_task_file.stem
116
  value = environment.get(key=key, default=False, dtype=bool)
117
  logger.info(f"{key}: {value}")
 
118
  if value is True:
119
  task_manager.add_tasks_by_task_file(tasks_file=porter_task_file.as_posix())
 
120
  task_thread = threading.Thread(
121
  target=async_thread_wrapper,
122
  args=(task_manager.run(),),
tabs/space_manage_tab.py CHANGED
@@ -92,7 +92,7 @@ def get_space_manage_tab():
92
  key="rebuild_switch",
93
  value=value
94
  )
95
- runtime = api.get_space_runtime(repo_id=space_name)
96
  result = {
97
  "stage": runtime.stage,
98
  }
 
92
  key="rebuild_switch",
93
  value=value
94
  )
95
+ runtime = api.restart_space(repo_id=space_name)
96
  result = {
97
  "stage": runtime.stage,
98
  }
toolbox/space_manager/cyclic/cyclic.py CHANGED
@@ -5,7 +5,10 @@ from datetime import datetime, timedelta
5
  import logging
6
  import json
7
  import os
8
- from typing import Coroutine, Dict, List, Tuple, Union, Iterable
 
 
 
9
 
10
  logger = logging.getLogger("toolbox")
11
 
@@ -15,21 +18,20 @@ from project_settings import environment, project_path, time_zone_info
15
 
16
 
17
  class AsyncDelayTask(object):
18
- def __init__(self, delay: float, coro_or_future: Union[Coroutine, asyncio.Future]):
 
 
 
 
19
  self.delay = delay
20
- self.coro_or_future = coro_or_future
 
 
21
 
22
  async def run(self):
23
  await asyncio.sleep(self.delay)
24
- return await self.coro_or_future
25
-
26
-
27
- async def remove_file(filename: str):
28
- try:
29
- logger.info(f"删除文件:{filename}")
30
- os.remove(filename)
31
- except FileNotFoundError:
32
- logger.info(f"文件不存在,跳过删除:{filename}")
33
 
34
 
35
  class CyclicSpaceManager(object):
@@ -130,7 +132,7 @@ class CyclicSpaceManager(object):
130
  task = asyncio.ensure_future(
131
  AsyncDelayTask(
132
  delay=delay_time,
133
- coro_or_future=rebuild_space()
134
  ).run()
135
  )
136
  # await task
 
5
  import logging
6
  import json
7
  import os
8
+ from typing import List, Callable, Awaitable, TypeVar
9
+
10
+ T = TypeVar('T')
11
+
12
 
13
  logger = logging.getLogger("toolbox")
14
 
 
18
 
19
 
20
  class AsyncDelayTask(object):
21
+ def __init__(self,
22
+ delay: float,
23
+ fn: Callable[..., Awaitable[T]],
24
+ *args, **kwargs
25
+ ):
26
  self.delay = delay
27
+ self.fn = fn
28
+ self.args = args
29
+ self.kwargs = kwargs
30
 
31
  async def run(self):
32
  await asyncio.sleep(self.delay)
33
+ result = await self.fn(*self.args, **self.kwargs)
34
+ return result
 
 
 
 
 
 
 
35
 
36
 
37
  class CyclicSpaceManager(object):
 
132
  task = asyncio.ensure_future(
133
  AsyncDelayTask(
134
  delay=delay_time,
135
+ fn=rebuild_space
136
  ).run()
137
  )
138
  # await task