Skip to content

Commit ff83f8f

Browse files
Merge pull request #271 from runpod/core-fix
Core fix
2 parents 8287a38 + c0222a7 commit ff83f8f

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

.github/tests.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,24 @@
5757
"value3"
5858
]
5959
}
60+
},
61+
{
62+
"hardwareConfig": {
63+
"endpointConfig": {
64+
"gpuIds": "ADA_24,AMPERE_16,AMPERE_24,AMPERE_48,AMPERE_80",
65+
"name": "runpod-python E2E Test - Serverless Core"
66+
},
67+
"templateConfig": {
68+
"env": [
69+
{
70+
"key": "RUNPOD_USE_CORE",
71+
"value": "true"
72+
}
73+
]
74+
}
75+
},
76+
"input": {
77+
"mock_return": "this worked!"
78+
}
6079
}
6180
]

runpod/serverless/core.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def finish_stream(self, job_id: str) -> bool:
170170

171171

172172
# -------------------------------- Process Job ------------------------------- #
173-
def _process_job(handler: Callable, job: Dict[str, Any]) -> Dict[str, Any]:
173+
async def _process_job(handler: Callable, job: Dict[str, Any]) -> Dict[str, Any]:
174174
""" Process a single job. """
175175
hook = Hook()
176176

@@ -207,18 +207,21 @@ async def run(config: Dict[str, Any]) -> None:
207207
while True:
208208
jobs = hook.get_jobs(max_concurrency, max_jobs)
209209

210-
if len(jobs) == 0:
210+
if len(jobs) == 0 or jobs is None:
211211
continue
212212

213213
for job in jobs:
214-
asyncio.create_task(_process_job(handler, job))
214+
asyncio.create_task(_process_job(handler, job), name=job['id'])
215215
await asyncio.sleep(0)
216216

217217
await asyncio.sleep(0)
218218

219219

220220
def main(config: Dict[str, Any]) -> None:
221221
"""Run the worker in an asyncio event loop."""
222+
if config.get('handler') is None:
223+
raise ValueError("config must contain a handler function")
224+
222225
try:
223226
work_loop = asyncio.new_event_loop()
224227
asyncio.ensure_future(run(config), loop=work_loop)

0 commit comments

Comments
 (0)