Python Forum
Why does this hang the system up
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why does this hang the system up
#7
Does this help?

class PasswordFoundException (Exception):
    pass

def attempt(w, pw):
    
    # sys.stdout.write("\r")

    # sys.stdout.write("\rAttempt #%d: %s" % (counter.value, pw)) #prints simple progress with # in list that is tested and the pw string
    sys.stdout.write("Attempt #%d: %s\n" % (counter.value, pw)) #prints simple progress with # in list that is tested and the pw string

    sys.stdout.flush()
    #print(counter.value)
    counter.increment()

    if len(pw) < 10:
        return ""
    
    try:
        o = decode_keystore_json(w,pw)
        print("Password is: ", pw, "   ", o)
        
        raise PasswordFoundException("Password Found")
        
    except ValueError as e:
        # print(e)
        return ""

class Counter(object):
    def __init__(self):
        self.val = multiprocessing.Value('i', 0)

    def increment(self, n=1):
        with self.val.get_lock():
            self.val.value += n

    @property
    def value(self):
        return self.val.value

def __main__():
    global counter
    counter = Counter()
    pwds = []
    pwds = itertools.chain(pwds, generate_all(grammar,''))

    try:
        Parallel(n_jobs=-1)(delayed(attempt)(w, pw) for pw in pwds)

    except Exception as e:
        traceback.print_exc()
        while True:
            sys.stdout.write('\a')
            sys.stdout.flush()

if __name__ == "__main__":
    __main__()
Reply


Messages In This Thread
Why does this hang the system up - by Able98 - Jun-07-2017, 07:59 PM
RE: Why does this hang the system up - by Ofnuts - Jun-07-2017, 08:25 PM
RE: Why does this hang the system up - by Able98 - Jun-08-2017, 12:39 AM
RE: Why does this hang the system up - by Ofnuts - Jun-08-2017, 08:01 AM
RE: Why does this hang the system up - by Able98 - Jun-08-2017, 11:44 AM
RE: Why does this hang the system up - by Ofnuts - Jun-08-2017, 12:38 PM
RE: Why does this hang the system up - by Able98 - Jun-08-2017, 01:02 PM
RE: Why does this hang the system up - by nilamo - Jun-08-2017, 04:46 PM
RE: Why does this hang the system up - by Able98 - Jun-08-2017, 07:07 PM
RE: Why does this hang the system up - by nilamo - Jun-09-2017, 12:16 AM
RE: Why does this hang the system up - by Able98 - Jun-09-2017, 08:29 AM
RE: Why does this hang the system up - by Able98 - Jun-09-2017, 09:03 PM
RE: Why does this hang the system up - by wavic - Jun-09-2017, 01:45 PM
RE: Why does this hang the system up - by Gil77 - Sep-01-2017, 11:40 AM
RE: Why does this hang the system up - by nilamo - Sep-02-2017, 09:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Difference between os.system("clear") and os.system("cls") chmsrohit 7 16,798 Jan-11-2021, 06:30 PM
Last Post: ykumar34
  multiprocess hang when certain number is used in the program esphi 7 3,304 Nov-06-2020, 03:49 PM
Last Post: esphi
Question Difference between Python's os.system and Perl's system command Agile741 13 6,994 Dec-02-2019, 04:41 PM
Last Post: Agile741
  Hang man game supermane 2 2,288 Aug-15-2018, 12:07 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020