mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 14:24:09 +01:00
msggen: Use tempfile + rename to make changes to .msggen.json atomic
This was causing issues when multiple instances of msggen were running in parallel on CI. Changelog-None
This commit is contained in:
parent
17b9bd5ca3
commit
b55df5c626
1 changed files with 4 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
|||
import json
|
||||
import os
|
||||
from msggen.gen.grpc import GrpcGenerator, GrpcConverterGenerator, GrpcUnconverterGenerator, GrpcServerGenerator
|
||||
from msggen.gen.grpc2py import Grpc2PyGenerator
|
||||
from msggen.gen.rust import RustGenerator
|
||||
|
@ -41,8 +42,10 @@ def load_msggen_meta():
|
|||
|
||||
|
||||
def write_msggen_meta(meta):
|
||||
with open('.msggen.json', 'w') as f:
|
||||
pid = os.getpid()
|
||||
with open(f'.msggen.json.tmp.{pid}', 'w') as f:
|
||||
json.dump(meta, f, sort_keys=True, indent=4)
|
||||
os.rename(f'.msggen.json.tmp.{pid}', '.msggen.json')
|
||||
|
||||
|
||||
def run():
|
||||
|
|
Loading…
Add table
Reference in a new issue