Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
package_alerts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
Container 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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
linuxsupport
cronjobs
package_alerts
Commits
dd5b76fc
Commit
dd5b76fc
authored
1 year ago
by
Ben Morrice
Browse files
Options
Downloads
Patches
Plain Diff
Add logic to fail script if it's taking too long
parent
bb3c34e4
No related branches found
No related tags found
No related merge requests found
Pipeline
#6382707
passed
1 year ago
Stage: build
Stage: deploy_test
Stage: deploy
Stage: cleanup
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
package_alerts/package_alerts
+13
-1
13 additions, 1 deletion
package_alerts/package_alerts
with
13 additions
and
1 deletion
package_alerts/package_alerts
+
13
−
1
View file @
dd5b76fc
...
...
@@ -5,9 +5,11 @@ import glob
import
html
import
json
import
re
import
signal
import
subprocess
import
sys
import
tempfile
import
time
from
collections
import
ChainMap
from
datetime
import
datetime
import
dnf
...
...
@@ -157,7 +159,13 @@ def get_upstream(token, feed):
offset
=
0
packages
=
[]
while
True
:
result
=
call_api
(
token
,
url
,
params
=
{
"
limit
"
:
100
,
"
offset
"
:
offset
})
signal
.
signal
(
signal
.
SIGALRM
,
timeout_handler
)
signal
.
alarm
(
30
)
try
:
result
=
call_api
(
token
,
url
,
params
=
{
"
limit
"
:
100
,
"
offset
"
:
offset
})
except
TimeoutError
:
print
(
f
"
Timeout occurred whilst trying to process
{
feed
}
with offset
{
offset
}
"
)
continue
try
:
j
=
json
.
loads
(
result
.
content
)
except
json
.
decoder
.
JSONDecodeError
:
...
...
@@ -258,6 +266,10 @@ def format_release(p, f, token):
)
print
(
f
"
-- Payload sent:
{
payload
}
"
,
flush
=
True
)
def
timeout_handler
(
num
,
stack
):
"""
function to handle timeouts for long running function
"""
print
(
"
Received SIGALRM
"
)
raise
TimeoutError
if
__name__
==
"
__main__
"
:
"""
this is the main class, it
'
s amazing.
"""
...
...
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