Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dokos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
cylab
Dokos
Commits
c1a87bd6
Commit
c1a87bd6
authored
2 years ago
by
Thibault Debatty
Browse files
Options
Downloads
Patches
Plain Diff
add global RUN flag to stop the threads if needed
parent
264c5a97
No related branches found
No related tags found
No related merge requests found
Pipeline
#10423
failed
2 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/dokos/dokos.py
+7
-1
7 additions, 1 deletion
src/dokos/dokos.py
with
7 additions
and
1 deletion
src/dokos/dokos.py
+
7
−
1
View file @
c1a87bd6
...
...
@@ -16,6 +16,7 @@ import validators
# https://superfastpython.com/thread-safe-print-in-python/
LOCK
=
Lock
()
RUN
=
True
ARGS
=
None
FOUND
=
[]
...
...
@@ -80,6 +81,9 @@ def try_passwords(passwords):
'''
for
password
in
passwords
:
# we were interrupted by user
if
not
RUN
:
break
password
=
password
.
strip
()
print_safe
(
"
login:
"
+
ARGS
.
login
+
"
password:
"
+
password
)
try_password
(
password
)
...
...
@@ -179,7 +183,7 @@ def main():
# https://stackoverflow.com/a/15143994
executor
=
concurrent
.
futures
.
ThreadPoolExecutor
(
ARGS
.
threads
)
futures
=
[
executor
.
submit
(
try_passwords
,
group
)
for
group
in
batched
(
passwords
,
10
)]
for
group
in
batched
(
passwords
,
ppt
)]
# https://stackoverflow.com/a/65207578
try
:
...
...
@@ -187,6 +191,8 @@ def main():
except
KeyboardInterrupt
:
# User interrupt the program with ctrl+c
print_safe
(
"
Stopping threads...
"
)
global
RUN
RUN
=
False
executor
.
shutdown
(
wait
=
True
,
cancel_futures
=
True
)
sys
.
exit
()
...
...
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