Skip to content

race condition when multiple terminals open at once, and write completer's gh.ps1 #2

@ninmonkey

Description

@ninmonkey

Sometimes there's a race condition.

Import-Module: C:\Users\cppmo_000\Documents\2021\dotfiles_git\powershell\Nin-CurrentUserAllHosts.ps1:217
Line |
 217 |      Import-Module -Name $p -Force #-ea stop
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The process cannot access the file
     | 'C:\Users\cppmo_000\.ninmonkey\completers\gh.ps1' because it is being
     | used by another process.

Resolution, either:

A) tiny sleep and retry once
B) don't recreate / write completers on all executions of profile -- read, but write once.
C) mutex on write

( multiple attempts to write are causing the problem )

Minimal mutex, so B + C in a wrapper is possibly the best route, because multiple are used.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions