-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathTask_Scheduler_File_writer_Test.py
More file actions
136 lines (101 loc) · 3.5 KB
/
Task_Scheduler_File_writer_Test.py
File metadata and controls
136 lines (101 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
''' import csv
with open('d:\students.csv', 'w', newline='') as file:
writer = csv.writer(file)
writer.writerow(["SNo", "Name", "Subject"])
writer.writerow([1, "Ash Ketchum", "English"])
writer.writerow([2, "Gary Oak", "Mathematics"])
writer.writerow([3, "Brock Lesner", "Physics"])
'''
'''
from multiprocessing import Process, Manager
# Define a function that will run in a separate process
def process1(q):
# Put a string into the queue
q.put('hello')
# Define a function that will run in a separate process
def process2(q):
# Get a message from the queue and print it to the console
print(q.get())
# The following code will only run if the script is run directly
if __name__ == '__main__':
# Create an instance of the Manager
with Manager() as manager:
# Create a queue within the context of the manager
q = manager.Queue()
# Create two instances of the Process class, one for each function
p1 = Process(target=process1, args=(q,))
p2 = Process(target=process2, args=(q,))
# Start both processes
p1.start()
p2.start()
# Wait for both processes to finish
p1.join()
p2.join()
import multiprocessing
import os
print("Number of cpu : ", os.cpu_count())
print("Number of cpu : ", multiprocessing.cpu_count())'''
import multiprocessing
import time
from ChartInk_Scaper_FileWatcher_Processor import Watcher
''''''
def process1(queue):
# Your logic for process 1 here
# Communicate with the queue as needed
print("Process 1 started")
watcher = Watcher()
watcher.run(queue)
time.sleep(1) # Placeholder for actual work
print("Process 1 completed")
def process2(queue):
# Your logic for process 2 here
# Communicate with the queue as needed
print("Process 2 started")
time.sleep(1) # Placeholder for actual work
print("Process 2 completed")
if __name__ == "__main__":
# Create a multiprocessing queue
queue = multiprocessing.Queue()
# Start the processes
p1 = multiprocessing.Process(target=process1, args=(queue,))
p2 = multiprocessing.Process(target=process2, args=(queue,))
# Set the start and end times
''' start_time = time.strptime("09:15", "%H:%M")
end_time = time.strptime("15:30", "%H:%M")
# Wait until the start time
current_time = time.localtime()
import datetime
from datetime import datetime
current_time = datetime.now().strftime("%H:%M")
while current_time < start_time:
time.sleep(60) # Check every minute
current_time = time.localtime() '''
while True:
import datetime
from datetime import datetime, time
current_time = datetime.now().time()
# Define the start and end times
start_time = time(18, 55)#time(9, 11)
end_time = time(18, 58)#time(15, 30)
# Check if the current time is between start_time and end_time
if current_time < start_time :
#logging.info("Current time is between 9:15 AM and 3:30 PM.")
continue
else:
print("Markets open only between 9:15 AM and 3:30 PM.")
break
# Start the processes
p1.start()
p2.start()
# Wait until the end time
while current_time < end_time:
import time
time.sleep(30) # Check every minute
current_time = datetime.now().time()
# Terminate the processes
p1.terminate()
p2.terminate()
# Join the processes (optional)
p1.join()
p2.join()
print("Main program completed")'''