Wait for a process to finish

To wait for any process to finish Linux (doesn’t work on Alpine, where ash doesn’t support tail –pid): tail –pid=$pid -f /dev/null Darwin (requires that $pid has open files): lsof -p $pid +r 1 &>/dev/null With timeout (seconds) Linux: timeout $timeout tail –pid=$pid -f /dev/null Darwin (requires that $pid has open files): lsof -p $pid … Read more

How to tell PowerShell to wait for each command to end before starting the next?

Normally, for internal commands PowerShell does wait before starting the next command. One exception to this rule is external Windows subsystem based EXE. The first trick is to pipeline to Out-Null like so: Notepad.exe | Out-Null PowerShell will wait until the Notepad.exe process has been exited before continuing. That is nifty but kind of subtle … Read more

How to wait some time in pygame?

For animation / cooldowns, etc: If you want to ‘wait’, but still have code running you use: pygame.time.get_ticks class Unit(): def __init__(self): self.last = pygame.time.get_ticks() self.cooldown = 300 def fire(self): # fire gun, only if cooldown has been 0.3 seconds since last now = pygame.time.get_ticks() if now – self.last >= self.cooldown: self.last = now spawn_bullet()