Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
binary_c-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Izzard, Robert Dr (Maths & Physics)
binary_c-python
Commits
91113467
Commit
91113467
authored
3 years ago
by
Izzard
Browse files
Options
Downloads
Patches
Plain Diff
added NFS file locking with flufl.lock()
parent
b0d8e176
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
binarycpython/utils/HPC.py
+28
-11
28 additions, 11 deletions
binarycpython/utils/HPC.py
with
28 additions
and
11 deletions
binarycpython/utils/HPC.py
+
28
−
11
View file @
91113467
...
...
@@ -9,6 +9,7 @@
Condor API.
"""
import
datetime
import
flufl.lock
import
glob
import
os
import
pathlib
...
...
@@ -79,17 +80,33 @@ class HPC(condor,slurm):
self
.
exit
(
code
=
1
)
x
=
False
else
:
# write the joiningfile
print
(
"
Making joiningfile at {file} with range 0 to {n}
"
.
format
(
file
=
file
,
n
=
n
))
with
open
(
file
,
"
w
"
,
encoding
=
"
utf-8
"
)
as
f
:
for
i
in
range
(
0
,
n
):
f
.
write
(
os
.
path
.
join
(
prefix
,
"
{i}.gz
\n
"
.
format
(
i
=
i
)))
f
.
close
()
x
=
True
# lock the joiningfile
lock
=
flufl
.
lock
.
Lock
(
file
)
# writing this file should not take > 1 hour
lock
.
lifetime
=
datetime
.
timedelta
(
seconds
=
3600
)
if
os
.
path
.
isfile
(
file
):
print
(
"
Cannot make joiningfile at {file} because it already exists.
"
.
format
(
file
=
file
))
x
=
False
else
:
if
lock
.
is_locked
:
# write the joiningfile
print
(
"
Making joiningfile at {file} with range 0 to {n}
"
.
format
(
file
=
file
,
n
=
n
))
with
open
(
file
,
"
w
"
,
encoding
=
"
utf-8
"
)
as
f
:
for
i
in
range
(
0
,
n
):
f
.
write
(
os
.
path
.
join
(
prefix
,
"
{i}.gz
\n
"
.
format
(
i
=
i
)))
x
=
True
else
:
print
(
"
Could not lock joiningfile at {file}
"
.
format
(
file
=
file
))
x
=
False
# unlock the file
lock
.
unlock
()
return
x
def
HPC_joinfiles
(
self
,
joinlist
=
None
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment