Created
December 26, 2013 04:51
-
-
Save JoshuaJB/8129948 to your computer and use it in GitHub Desktop.
Patch to enable profiling using yappi on the WFG 0 A.D. lobby bot.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: source/tools/XpartaMuPP/XpartaMuPP.py | |
=================================================================== | |
--- source/tools/XpartaMuPP/XpartaMuPP.py (revision 14390) | |
+++ source/tools/XpartaMuPP/XpartaMuPP.py (working copy) | |
@@ -16,7 +16,7 @@ | |
* You should have received a copy of the GNU General Public License | |
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | |
""" | |
- | |
+import yappi | |
import logging, time, traceback | |
from optparse import OptionParser | |
@@ -401,7 +401,6 @@ | |
self.iqhandler, | |
instream=True)) | |
self.add_event_handler("session_start", self.start) | |
- self.add_event_handler("session_start", self.start) | |
self.add_event_handler("muc::%s::got_online" % self.room, self.muc_online) | |
self.add_event_handler("muc::%s::got_offline" % self.room, self.muc_offline) | |
@@ -425,6 +424,7 @@ | |
# Check the jid isn't already in the lobby. | |
if str(presence['muc']['jid']) != self.lastLeft: | |
self.send_message(mto=presence['from'], mbody="Hello %s, welcome to the 0 A.D. lobby. Polish your weapons and get ready to fight!" %(presence['muc']['nick']), mtype='') | |
+ self.send_message(mto=presence['from'], mbody="WARNING: The lobby is currently undergoing preventive maintenance and may misbehave or malfunction.") | |
# Send Gamelist to new player. | |
self.sendGameList(presence['muc']['jid']) | |
# Following two calls make sqlalchemy complain about using objects in the | |
@@ -470,6 +470,8 @@ | |
self.sendGameList(iq['from']) | |
self.leaderboard.getOrCreatePlayer(iq['from']) | |
self.sendBoardList(iq['from']) | |
+ if str(iq['from']) == 'josh@lobby.wildfiregames.com/0ad': | |
+ yappi.print_stats(limit=20) | |
except: | |
traceback.print_exc() | |
logging.error("Failed to process list request from %s" % iq['from'].bare) | |
@@ -668,7 +670,7 @@ | |
# Setup logging. | |
logging.basicConfig(level=opts.loglevel, | |
format='%(levelname)-8s %(message)s') | |
- | |
+ yappi.start() | |
# XpartaMuPP | |
xmpp = XpartaMuPP(opts.xlogin+'@'+opts.xdomain+'/CC', opts.xpassword, opts.xroom+'@conference.'+opts.xdomain, opts.xnickname) | |
xmpp.register_plugin('xep_0030') # Service Discovery |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment