Navigation X
ALERT
Click here to register with a few steps and explore all our cool stuff we have to offer!



   2599

Need Help With Python Combo Editor

by hugs - 26 December, 2021 - 01:38 AM
This post is by a banned member (clap) - Unhide
clap  
Godlike
519
Posts
134
Threads
6 Years of service
#9
(This post was last modified: 28 December, 2021 - 04:32 PM by clap. Edited 1 time in total.)
When you're dealing with non thread-safe tasks, use the lock. As an example, if you wanted to say call print, it wouldn't go smooth and multiple statements would be executed at the same time resulting in overlaps (text on same line). This would be a perfect time to call the lock.

Note: You should look into queues.
 
Code:
import threading


lock = threading.Lock()

def worker():
     with lock:
            print('Text')

# Or

def worker():
     lock.acquire()
     print('Text')
     lock.release()
Always confirm via PM before dealing with me.
This post is by a banned member (Zentred) - Unhide
Zentred  
Infinity
611
Posts
124
Threads
4 Years of service
#10
(This post was last modified: 01 January, 2022 - 02:15 PM by Zentred. Edited 1 time in total.)
(26 December, 2021 - 01:38 AM)hugs Wrote: Show More
Ok, so I'm trying to make a fast editor that takes passwords from a password list, and users from a username list, and appends every password in the list to each username

for example:
 
Code:
user1:pass1
user1:pass2
user1:pass3
user2:pass1
user2:pass2
user2:pass3
...

And so on, so forth.


I easily made the folowing code that WORKS, however it is painfully slow when I need to generate a list that will be 9,000,000 lines large.

My current code:
 
Code:
usernames = open("Usernames.txt").read().splitlines()

passwords = open("Passwords.txt").read().splitlines()

for username in usernames:
    for password in passwords:
        with open("Combo.txt", "a+") as combofile:
            combofile.write(f"{username}:{password}\n")

This code again works just fine, however it is PAINFULLY slow when the end result (the combo) is expected to be around 9,000,000 lines. 
I attempted to add multithreading, however the text file became way too large, had messed up lines, duplicates, etc.

If there is any way I can speed this process up drastically, please let me know!

threading doesnt really help with this working with something like this
but maybe your proble is you're opening the combo.txt file every for loop, so you would open it 9 million times

instead to look better and easier u can do
Code:
 
import time
usernames = open("users.txt").read().splitlines()
passwords = open("passwords.txt").read().splitlines()
start = time.process_time()
with open('output.txt','a',errors='ignore') as combofile:
    combofile.writelines([f'{user}:{password}\n' for user in usernames for password in passwords])
print(time.process_time() - start)

time taken = 6.515625 secoonds
This post is by a banned member (DankoFR) - Unhide
DankoFR  
Godlike
1.780
Posts
809
Threads
4 Years of service
#11
add threading lol

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
or
Sign in
Already have an account? Sign in here.


Forum Jump:


Users browsing this thread: 1 Guest(s)