XMLRPC Server Slow in Python – How to Fix

February 19th, 2010  / Author: Greg Pinero (Primary Searcher)

Background:
I had set up a Python XML-RPC server on one machine. When accessing the web services from other machines it would sometimes take up to 20 seconds to get a response. The strange thing was that this only happened when accessing the web service from some machines but not others.

Problem and Solution:
It turns out that Python’s BaseHTTPRequestHandler was trying to log the fully qualified domain name of each request’s IP address. Thus when we connected from machines that didn’t have a fully qualified domain name, it would take a long time to not find the FQDN. There is actually a bug for this.

Below is a simple fix that solved the problem for me (in Python 2.4). This would probably work in future versions too.

Assume this is your basic XMLRPC Server set up in Python:

import SimpleXMLRPCServer

class FuncGroup:
    """Just hold the funcs to be used in web service"""
    def hi(self,val):
        return "hi there"

#create server and start it
server_address = ('localhost',8000) # (address, port)
server = SimpleXMLRPCServer.SimpleXMLRPCServer(server_address)
server.register_instance(FuncGroup()) #reg. functions/class instance
server.serve_forever()


Here is the fixed version. I added in an override for the trouble function:

import SimpleXMLRPCServer

#new code
import BaseHTTPServer
def not_insane_address_string(self):
    host, port = self.client_address[:2]
    return '%s (no getfqdn)' % host #used to call: socket.getfqdn(host)
BaseHTTPServer.BaseHTTPRequestHandler.address_string = \
    not_insane_address_string
#end new code

class FuncGroup:
    """Just hold the funcs to be used in web service"""
    def hi(self,val):
        return "hi there"

#create server and start it
server_address = ('localhost',8000) # (address, port)
server = SimpleXMLRPCServer.SimpleXMLRPCServer(server_address)
server.register_instance(FuncGroup()) #reg. functions/class instance
server.serve_forever()

Search Google For … From New York Times Page Goes to Blank Search Page

February 13th, 2010  / Author: Greg Pinero (Primary Searcher)

When I’m on a NYtimes.com webpage and I highlight some text, right click and select “Search Google For” it just opens up a blank search page in the new page. Every other page I’m on works fine with this.

Does anyone know what could be going on? I’ll post more answers as I find them.

I’m on Firefox 3.0.10 in Ubuntu Linux.

Does the iphone alarm still make noise when the phone is set to silent?

February 8th, 2010  / Author: Greg Pinero (Primary Searcher)

Indeed it does. I just tested it. Even though the phone is silent when a call comes in, your morning alarm will sound off just fine. (Disclaimer at least for me, don’t miss a NYC marathon to oversleeping on my advice!)

Reporting Services 2005 How to Display Data Point Labels Outside a Pie Chart

February 8th, 2010  / Author: Greg Pinero (Primary Searcher)

The labels on a pie chart in SQL Server 2005 Reporting Services (SSRS) are very ugly. They just get thrown over the chart by default and they all overlap. I hate it!

This MSDN page tells us how to fix it http://msdn.microsoft.com/en-us/library/ms156263(SQL.90).aspx

To change the position of point labels in a pie chart
Using Report Designer, create a pie chart. For more information, see Working with Chart Data Regions.

In Layout view, right-click the chart, and then click Properties.

On the Data tab, in Values, and then click Add or Edit to open the Edit Chart Value dialog box.

On the Point Labels tab, clear Auto, and then select a button other than the center button.

To set options on this tab, Show point labels must be selected.

SQL Server 2005 Reporting Services SSRS – Fixing Connection Error

February 1st, 2010  / Author: Greg Pinero (Primary Searcher)

I was completely stumped on this error that I was getting on the report manager web page after I uploaded an RDL file and set it use a shared connection I had already set up:

An error has occurred during report processing.
Cannot create a connection to data source 'TWO'.
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

It turns out I had simply mistyped my connection string when I was setting up the shared connection. So that’s something you should check first.