How to override the screensaver settings in the MATE desktop:
Solution 1
There are two settings you can work with:
- System Settings -> Brightness & Lock -> Turn screen off when inactive for
- System Settings -> Power -> Suspend when inactive for
The first will signal the display to turn itself off, the second will put the computer into a sleep state. I'm assuming you're referring to the first behavior.
That being said, remember that TVs don't behave the same way that monitors do. A monitor will go to sleep ("suspend") and wake up when instructed to, but most TVs don't implement suspend mode: they will display a "No Signal" message for a few minutes and then turn off.
You'll need a computer monitor if you want display suspend functionality.
Solution 2
Note:
I installed Mate from tasksel onto Ubuntu server. Consequently, it is the only window manager installed without additional features from Gnome or Unity installed.
Power management in Mate on Ubuntu:
Power management is what you need to adjust to prevent your computer from going to sleep.
- On the menu bar, select system.
- Then select control center.
- Then in the hardware section, select screen saver.
Screen saver settings in Mate on Ubuntu:
Another point of interest is the screen saver.
- On the menu bar, select system.
- Then select control center.
- In the personal section. select screen saver.
Additional notes:
- When Mate is the only window manager installed, Brightness and lock is not available and I am not sure it would even work in Mate.
- Many TVs will turn off to save power when it is not receiving a signal. This may or may not be adjustable on your TV, but it probably does not need to be adjusted after configuring power management and screen saver settings for Mate on Ubuntu.
- Screen-shots and instructions were performed on Ubuntu 15.10. If a procedure differs for other releases please add your comment so that I can add an update.
Related videos on Youtube
jbf
Updated on September 18, 2022Comments
-
jbf over 1 year
I have a program that simulates an entire baseball season, but does a lot of calculations per game, so each game takes around 30 seconds to run. With 2430 games in a season, the program takes about 20 hours to run, per season. Obviously I'd like to speed this up, so the most immediate solution seems like multiprocessing. I could manually split it up into groups of ~600 and run four processes, but I'd like to figure out how the multiprocessing module works.
Here's what I've tried so far, but obviously it doesn't work.
def test_func(): algorithm_selection = 1 # Create sqlite database connection conn = sqlite3.connect('C:/F5 Prediction Engine/sqlite3/Version 2/statcast_db.db') c = conn.cursor() season = input('Year to simulate: ') c.execute('SELECT * FROM gamelogs_' + season) season_games = c.fetchall() game_num = 0 for game in season_games: game_num = game_num + 1 #Get away lineup in terms of MLB IDs away_lineup = ConvertLineup(game[105], game[108], game[111], game[114], game[117], game[120], game[123], game[126], game[129]) #Get home lineup in terms of MLB IDs home_lineup = ConvertLineup(game[132], game[135], game[138], game[141], game[144], game[147], game[150], game[153], game[156]) #Get away starting pitcher and hand in terms of MLB ID away_pitcher_results = GetPitcherIDandHand(game[101]) away_pitcher_id = away_pitcher_results[0][0] away_pitcher_hand = away_pitcher_results[0][1] #Get home starting pitcher and hand in terms of MLB ID home_pitcher_results = GetPitcherIDandHand(game[103]) home_pitcher_id = home_pitcher_results[0][0] home_pitcher_hand = home_pitcher_results[0][1] #Get the date of the game today_date = game[0] if algorithm_selection == 1: #Check if the current game has already been evaluated and entered into the database c.execute('SELECT * FROM pemstein_results_' + season + ' WHERE date = "' + game[0] + '" AND away_team = "' + game[3] + '" AND home_team = "' + game[6] + \ '" AND away_team_score = "' + game[9] + '" AND home_team_score = "' + game[10] + '"') check_results = c.fetchall() if len(check_results) == 0: exp_slgs = PemsteinSimulation(home_pitcher_id, away_pitcher_id, season, home_pitcher_hand, away_pitcher_hand, home_lineup, away_lineup, game[0]) if exp_slgs[2] == 0: #if both pitches had at least 300 PAs to use for simulation c.execute([long string to insert results into database]) conn.commit() print('Game ' + str(game_num) + ' finished.') if exp_slgs[2] == 1: #if one of the pitches did not have enough PAs to qualify c.execute([long string to insert results into database]) conn.commit() print('Game ' + str(game_num) + ' finished.') if len(check_results) > 0: print('Game ' + str(game_num) + ' has already been evaluated.') from multiprocessing import Process import os processes = [] for i in range(0, os.cpu_count()): print('Registering process %d' % i) processes.append(Process(target=test)) for process in processes: process.start() for process in processes: process.join()
==================
Edit: new code
#Child Process def simulate_games(games_list, counter, lock): while(1): # Create sqlite database connection conn = sqlite3.connect('C:/F5 Prediction Engine/sqlite3/Version 2/statcast_db.db') c = conn.cursor() #acquire the lock which grants access to the shared variable with lock: #check the termination condition if counter >= len(games_list): break #get the game_num and game to simulate game_num = counter.value game_to_simulate = game_list[counter.value] #update the counter for the next process counter.value += 1 #Do simulation game_num = 0 game_num = game_num + 1 #Get away lineup in terms of MLB IDs away_lineup = ConvertLineup(game_to_simulate[105], game_to_simulate[108], game_to_simulate[111], game_to_simulate[114], game_to_simulate[117], game_to_simulate[120], game_to_simulate[123], game_to_simulate[126], game_to_simulate[129]) #Get home lineup in terms of MLB IDs home_lineup = ConvertLineup(game_to_simulate[132], game_to_simulate[135], game_to_simulate[138], game_to_simulate[141], game_to_simulate[144], game_to_simulate[147], game_to_simulate[150], game_to_simulate[153], game_to_simulate[156]) #Get away starting pitcher and hand in terms of MLB ID away_pitcher_results = GetPitcherIDandHand(game[101]) away_pitcher_id = away_pitcher_results[0][0] away_pitcher_hand = away_pitcher_results[0][1] #Get home starting pitcher and hand in terms of MLB ID home_pitcher_results = GetPitcherIDandHand(game[103]) home_pitcher_id = home_pitcher_results[0][0] home_pitcher_hand = home_pitcher_results[0][1] #Get the date of the game today_date = game_to_simulate[0] if algorithm_selection == 1: #Check if the current game has already been evaluated and entered into the database c.execute('SELECT * FROM pemstein_results_' + season + ' WHERE date = "' + game_to_simulate[0] + '" AND away_team = "' + game_to_simulate[3] + '" AND home_team = "' + game_to_simulate[6] + \ '" AND away_team_score = "' + game_to_simulate[9] + '" AND home_team_score = "' + game_to_simulate[10] + '"') check_results = c.fetchall() if len(check_results) == 0: exp_slgs = PemsteinSimulation(home_pitcher_id, away_pitcher_id, season, home_pitcher_hand, away_pitcher_hand, home_lineup, away_lineup, game_to_simulate[0]) if exp_slgs[2] == 0: #if both pitches had at least 300 PAs to use for simulation c.execute('long sql') conn.commit() print('Game ' + str(game_num) + ' finished.') if exp_slgs[2] == 1: #if one of the pitches did not have enough PAs to qualify c.execute('long sql') conn.commit() print('Game ' + str(game_num) + ' finished.') if len(check_results) > 0: print('Game ' + str(game_num) + ' has already been evaluated.') if __name__ == "__main__": # Create sqlite database connection conn = sqlite3.connect('C:/F5 Prediction Engine/sqlite3/Version 2/statcast_db.db') c = conn.cursor() #Query all games for season to be simulated season = int(input('Year to simulate: ')) c.execute('SELECT * FROM gamelogs_' + str(season)) season_games = c.fetchall() algorithmSelection = 1 if algorithmSelection == 1: PemsteinSQLresults(str(season)) counter = mp.Value('i', 0) lock = mp.Lock() children = [] for i in range(os.cpu_count()): children.append(mp.Process(target=simulate_games, args=(season_games, counter, lock))) for child in children: child.start() for child in children: child.join()
Error:
Traceback (most recent call last): File "C:\F5 Prediction Engine\Version 2\SimulateSeason v2.py", line 126, in <module> child.start() File "C:\Python\lib\multiprocessing\process.py", line 105, in start self._popen = self._Popen(self) File "C:\Python\lib\multiprocessing\context.py", line 223, in _Popen return _default_context.get_context().Process._Popen(process_obj) File "C:\Python\lib\multiprocessing\context.py", line 322, in _Popen return Popen(process_obj) File "C:\Python\lib\multiprocessing\popen_spawn_win32.py", line 65, in __init__ reduction.dump(process_obj, to_child) File "C:\Python\lib\multiprocessing\reduction.py", line 60, in dump ForkingPickler(file, protocol).dump(obj) BrokenPipeError: [Errno 32] Broken pipe
=============
So I went to this website to review some things, and tried a new script with the following code that I copied from the site:
import mp def worker(num): """thread worker function""" print('Worker:' + num) return if __name__ == '__main__': jobs = [] for i in range(5): p = mp.Process(target=worker, args=(i,)) jobs.append(p) p.start()
But it likewise doesn't do anything. The site says it should print
Worker:0
Worker:1
etc, but I'm getting no prints. Is it possible there's something wrong locally on my machine?-
Keith Reynolds over 8 yearsActual single strength strength will not change because your using Mate, Unity or Gnome. Single strength can change with objects that have moved, and placement or WIFI router and your WIFI device.
-
MisterMiyagi almost 5 yearsThat is a lot of code to expect people to understand. Is there any reason why you are manually creating and assigning a process per CPU, instead of using a multiprocessing Pool and its map functionality?
-
jbf almost 5 yearsI've tried to edit the code down to a minimum, there's a lot of stuff that I've left out. As for pool/map, I've never tried either. This is my first attempt at multiprocessing, and the first example of code that I posted was mostly copied from a guide that I found online.
-
-
user245115 over 9 yearsIt was set to never, and it looks like I forgot to mention that this only happens in MATE, not Unity or LXDE. What's even better is that I had another Samsung TV I used to use, but it broke down. It appears to be working normally, but when pressing the button it used to take about 5 seconds to boot, but now it's stuck in the boot process for HOURS, while the TV's shutdown is normal. when the PC was shut off when hooked to that, it did just what a monitor was supposed to, display no signal then turn off the display. Also, the PC is hooked via a standard VGA (or is it PCI?) cable.
-
jbf almost 5 yearsThanks for the help, that seems to have gotten me closer. I've edited the original post to show my new code. The only thing I changed from your post was to put the function above the multiprocessing code, because it said "simulate_games is not defined" when the function was defined below it. Now it gives me a BrokenPipeError. I've added the complete text of the error the the main post.
-
DLM almost 5 yearsGreat! So, I looked at your error message and did some searching: if you are using Windows it might be a problem related to the fact that you are not running you main (parent) code into
if __name__ == "__main__:"
, could you try that, if you are using windows? I would also like to point out a couple of things: first, you are using a cursor c inside your child process, but I suppose that it shouldn't be visible and you might have some problems, therefore you should either create a new one or pass the original one as an argument; second, you should eliminate thefor game in season_games
-
jbf almost 5 yearsI added
if __name__ == "__main__":
to the code, and changed the other two things. It now runs without errors, but it doesn't do anything. It runs for ~1.5 seconds and ends. I've re-edited the edit part of the main post to reflect the current code. -
DLM almost 5 yearsPerfect! I see that you are using an object
game
inside of your child process, but you haven't defined anything with such a name: shouldn't it begame_to_simulate
? -
jbf almost 5 yearsI changed all instances of
game
togame_to_simulate
, but still nothing. I also tried to addprint('working')
or something similar in the line immediately belowwhile(1):
to see if it would print that, but it doesn't, so is it possible that it's not getting that far? It seems like something is happening so that the function isn't being called, but I can't figure out what. -
DLM almost 5 yearsOk, I checked your code and there is a typo in the child:
game_list
->games_list
; also, the termination conditioncounter >= len( ... )
should instead becounter.value >= len( ... )
. Apart from these two issues, the code is working for me. -
jbf almost 5 yearsI fixed those two typos, still runs in about 1.5 seconds, without errors. I still can't figure out why it wouldn't print something that I put at the top of the simulate_games function, and if the game_list/games_list typo was ever being encountered, why wouldn't it give me an error with an undefined variable?
-
jbf almost 5 yearsI edited the main post again, potentially something wrong on my computer? A very basic mutliprocessing script I copied from another site as a test doesn't seem to be working either.
-
DLM almost 5 yearsLet us continue this discussion in chat.