Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def spawn(self, coro):
if self._closed:
raise RuntimeError("Scheduling a new job after closing")
job = Job(coro, self, self._loop)
should_start = (self._limit is None or
self.active_count < self._limit)
self._jobs.add(job)
if should_start:
job._start()
else:
# wait for free slot in queue
await self._pending.put(job)
return job