我在Linux机器(ubuntu)上创建了一个Python Web服务:import soaplib
import os
from soaplib.core.service import rpc, DefinitionBase, soap
from soaplib.core.model.primitive import String, Integer
from soaplib.core.server import wsgi
from soaplib.core.model.clazz import Array
def runcmd(cmd):
fout = os.popen(cmd)
out = fout.read()
return out
class LinuxServices(DefinitionBase):
@soap(String, String,_returns=Array(String))
def df(self,server, user):
L = []
cmd = 'df -hP | grep "/"'
output = runcmd(cmd).split('\n')
for n in xrange(len(output)-1):
out = output[n].split()
L.append('%s;%s' % (out[5], out[4]))
return L
if __name__=='__main__':
try:
from wsgiref.simple_server import make_server
soap_application = soaplib.core.Application([LinuxServices], 'tns')
wsgi_application = wsgi.Application(soap_application)
server = make_server('0.0.0.0', 7789, wsgi_application)
server.serve_forever()
except ImportError:
print "Error: example server code requires Python >= 2.5"
然后(在Windows 7上)我创建了一个Silverlight项目,在该项目中,我使用以下ws来获取linux服务器上的磁盘状态:
Silverlight项目中的服务:
^{pr2}$
调用第页的服务:protected override void OnNavigatedTo(NavigationEventArgs e)
{
LinuxServiceClient client = new LinuxServiceClient();
client.dfCompleted += new EventHandler(client_dfCompleted);
client.dfAsync();
}
void client_dfCompleted(object sender, dfCompletedEventArgs e)
{
DG.ItemsSource = e.Result;
DG.Visibility = System.Windows.Visibility.Visible;
}
我的问题是,当我导航到这个页面时,从ws(局域网中的ws)获取数据需要4-8秒。在
我真的可以等一等带宽。。。在
我的问题:
你有什么建议我能做些什么来加快这个过程?
系统信息:ubuntuser11.04版
Python:python2.7
Soaplib:Soaplib 2.0.0-beta2Windows:Windows 7 sp1
Silverlight:Silverlight 4