Mark Slee | 57cc25e | 2007-02-28 21:43:54 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
Mark Slee | c967656 | 2006-09-05 17:34:52 +0000 | [diff] [blame] | 2 | |
David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 3 | # |
| 4 | # Licensed to the Apache Software Foundation (ASF) under one |
| 5 | # or more contributor license agreements. See the NOTICE file |
| 6 | # distributed with this work for additional information |
| 7 | # regarding copyright ownership. The ASF licenses this file |
| 8 | # to you under the Apache License, Version 2.0 (the |
| 9 | # "License"); you may not use this file except in compliance |
| 10 | # with the License. You may obtain a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, |
| 15 | # software distributed under the License is distributed on an |
| 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 17 | # KIND, either express or implied. See the License for the |
| 18 | # specific language governing permissions and limitations |
| 19 | # under the License. |
| 20 | # |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 21 | from __future__ import division |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 22 | import sys, glob, time, os |
| 23 | sys.path.insert(0, glob.glob(os.path.join(os.path.dirname(__file__),'../../lib/py/build/lib.*'))[0]) |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 24 | from optparse import OptionParser |
Mark Slee | c967656 | 2006-09-05 17:34:52 +0000 | [diff] [blame] | 25 | |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 26 | parser = OptionParser() |
Roger Meier | f4eec7a | 2011-09-11 18:16:21 +0000 | [diff] [blame] | 27 | parser.add_option('--genpydir', type='string', dest='genpydir', |
| 28 | default='gen-py', |
| 29 | help='include this local directory in sys.path for locating generated code') |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 30 | parser.add_option("--port", type="int", dest="port", |
| 31 | help="port number for server to listen on") |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 32 | parser.add_option("--zlib", action="store_true", dest="zlib", |
| 33 | help="use zlib wrapper for compressed transport") |
| 34 | parser.add_option("--ssl", action="store_true", dest="ssl", |
| 35 | help="use SSL for encrypted transport") |
Roger Meier | 7615072 | 2014-05-31 22:22:07 +0200 | [diff] [blame] | 36 | parser.add_option('-v', '--verbose', action="store_const", |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 37 | dest="verbose", const=2, |
| 38 | help="verbose output") |
Roger Meier | 7615072 | 2014-05-31 22:22:07 +0200 | [diff] [blame] | 39 | parser.add_option('-q', '--quiet', action="store_const", |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 40 | dest="verbose", const=0, |
| 41 | help="minimal output") |
Roger Meier | 7615072 | 2014-05-31 22:22:07 +0200 | [diff] [blame] | 42 | parser.add_option('--protocol', dest="proto", type="string", |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 43 | help="protocol to use, one of: accel, binary, compact, json") |
Roger Meier | 7615072 | 2014-05-31 22:22:07 +0200 | [diff] [blame] | 44 | parser.add_option('--transport', dest="trans", type="string", |
| 45 | help="transport to use, one of: buffered, framed") |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 46 | parser.set_defaults(port=9090, verbose=1, proto='binary') |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 47 | options, args = parser.parse_args() |
| 48 | |
cdwijayarathna | 0d4072b | 2014-08-09 21:32:21 +0530 | [diff] [blame] | 49 | script_dir = os.path.dirname(__file__) #<-- absolute dir the script is in |
| 50 | sys.path.insert(0, os.path.join(script_dir, options.genpydir)) |
Roger Meier | f4eec7a | 2011-09-11 18:16:21 +0000 | [diff] [blame] | 51 | |
jfarrell | dbf2bb5 | 2014-07-09 23:37:12 -0400 | [diff] [blame] | 52 | from ThriftTest import ThriftTest |
Roger Meier | f4eec7a | 2011-09-11 18:16:21 +0000 | [diff] [blame] | 53 | from ThriftTest.ttypes import * |
Roger Meier | 1f554e1 | 2013-01-05 20:38:35 +0100 | [diff] [blame] | 54 | from thrift.Thrift import TException |
Roger Meier | f4eec7a | 2011-09-11 18:16:21 +0000 | [diff] [blame] | 55 | from thrift.transport import TTransport |
| 56 | from thrift.transport import TSocket |
| 57 | from thrift.transport import TZlibTransport |
| 58 | from thrift.protocol import TBinaryProtocol |
| 59 | from thrift.protocol import TCompactProtocol |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 60 | from thrift.protocol import TJSONProtocol |
Roger Meier | f4eec7a | 2011-09-11 18:16:21 +0000 | [diff] [blame] | 61 | from thrift.server import TServer, TNonblockingServer, THttpServer |
| 62 | |
| 63 | PROT_FACTORIES = {'binary': TBinaryProtocol.TBinaryProtocolFactory, |
| 64 | 'accel': TBinaryProtocol.TBinaryProtocolAcceleratedFactory, |
Roger Meier | 85fb6de | 2012-11-02 00:05:42 +0000 | [diff] [blame] | 65 | 'compact': TCompactProtocol.TCompactProtocolFactory, |
| 66 | 'json': TJSONProtocol.TJSONProtocolFactory} |
Roger Meier | f4eec7a | 2011-09-11 18:16:21 +0000 | [diff] [blame] | 67 | |
Mark Slee | c967656 | 2006-09-05 17:34:52 +0000 | [diff] [blame] | 68 | class TestHandler: |
| 69 | |
| 70 | def testVoid(self): |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 71 | if options.verbose > 1: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 72 | print 'testVoid()' |
Mark Slee | c967656 | 2006-09-05 17:34:52 +0000 | [diff] [blame] | 73 | |
| 74 | def testString(self, str): |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 75 | if options.verbose > 1: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 76 | print 'testString(%s)' % str |
Mark Slee | c967656 | 2006-09-05 17:34:52 +0000 | [diff] [blame] | 77 | return str |
| 78 | |
Nobuaki Sukegawa | a649e74 | 2015-09-21 13:53:25 +0900 | [diff] [blame] | 79 | def testBool(self, boolean): |
| 80 | if options.verbose > 1: |
| 81 | print 'testBool(%s)' % str(boolean).lower() |
| 82 | return boolean |
| 83 | |
Mark Slee | c967656 | 2006-09-05 17:34:52 +0000 | [diff] [blame] | 84 | def testByte(self, byte): |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 85 | if options.verbose > 1: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 86 | print 'testByte(%d)' % byte |
Mark Slee | c967656 | 2006-09-05 17:34:52 +0000 | [diff] [blame] | 87 | return byte |
| 88 | |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 89 | def testI16(self, i16): |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 90 | if options.verbose > 1: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 91 | print 'testI16(%d)' % i16 |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 92 | return i16 |
| 93 | |
| 94 | def testI32(self, i32): |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 95 | if options.verbose > 1: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 96 | print 'testI32(%d)' % i32 |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 97 | return i32 |
| 98 | |
| 99 | def testI64(self, i64): |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 100 | if options.verbose > 1: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 101 | print 'testI64(%d)' % i64 |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 102 | return i64 |
| 103 | |
| 104 | def testDouble(self, dub): |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 105 | if options.verbose > 1: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 106 | print 'testDouble(%f)' % dub |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 107 | return dub |
| 108 | |
Jens Geyer | 8bcfdd9 | 2014-12-14 03:14:26 +0100 | [diff] [blame] | 109 | def testBinary(self, thing): |
| 110 | if options.verbose > 1: |
| 111 | print 'testBinary()' # TODO: hex output |
| 112 | return thring |
| 113 | |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 114 | def testStruct(self, thing): |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 115 | if options.verbose > 1: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 116 | print 'testStruct({%s, %d, %d, %d})' % (thing.string_thing, thing.byte_thing, thing.i32_thing, thing.i64_thing) |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 117 | return thing |
| 118 | |
Roger Meier | 1f554e1 | 2013-01-05 20:38:35 +0100 | [diff] [blame] | 119 | def testException(self, arg): |
| 120 | #if options.verbose > 1: |
| 121 | print 'testException(%s)' % arg |
| 122 | if arg == 'Xception': |
| 123 | raise Xception(errorCode=1001, message=arg) |
| 124 | elif arg == 'TException': |
| 125 | raise TException(message='This is a TException') |
| 126 | |
| 127 | def testMultiException(self, arg0, arg1): |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 128 | if options.verbose > 1: |
Roger Meier | 1f554e1 | 2013-01-05 20:38:35 +0100 | [diff] [blame] | 129 | print 'testMultiException(%s, %s)' % (arg0, arg1) |
| 130 | if arg0 == 'Xception': |
| 131 | raise Xception(errorCode=1001, message='This is an Xception') |
| 132 | elif arg0 == 'Xception2': |
| 133 | raise Xception2( |
| 134 | errorCode=2002, |
| 135 | struct_thing=Xtruct(string_thing='This is an Xception2')) |
| 136 | return Xtruct(string_thing=arg1) |
Mark Slee | c967656 | 2006-09-05 17:34:52 +0000 | [diff] [blame] | 137 | |
David Reiss | 6ce401d | 2009-03-24 20:01:58 +0000 | [diff] [blame] | 138 | def testOneway(self, seconds): |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 139 | if options.verbose > 1: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 140 | print 'testOneway(%d) => sleeping...' % seconds |
| 141 | time.sleep(seconds / 3) # be quick |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 142 | if options.verbose > 1: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 143 | print 'done sleeping' |
David Reiss | db893b6 | 2008-02-18 02:11:48 +0000 | [diff] [blame] | 144 | |
David Reiss | 7442127 | 2008-11-07 23:09:31 +0000 | [diff] [blame] | 145 | def testNest(self, thing): |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 146 | if options.verbose > 1: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 147 | print 'testNest(%s)' % thing |
David Reiss | 7442127 | 2008-11-07 23:09:31 +0000 | [diff] [blame] | 148 | return thing |
| 149 | |
| 150 | def testMap(self, thing): |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 151 | if options.verbose > 1: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 152 | print 'testMap(%s)' % thing |
David Reiss | 7442127 | 2008-11-07 23:09:31 +0000 | [diff] [blame] | 153 | return thing |
| 154 | |
| 155 | def testSet(self, thing): |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 156 | if options.verbose > 1: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 157 | print 'testSet(%s)' % thing |
David Reiss | 7442127 | 2008-11-07 23:09:31 +0000 | [diff] [blame] | 158 | return thing |
| 159 | |
| 160 | def testList(self, thing): |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 161 | if options.verbose > 1: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 162 | print 'testList(%s)' % thing |
David Reiss | 7442127 | 2008-11-07 23:09:31 +0000 | [diff] [blame] | 163 | return thing |
| 164 | |
| 165 | def testEnum(self, thing): |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 166 | if options.verbose > 1: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 167 | print 'testEnum(%s)' % thing |
David Reiss | 7442127 | 2008-11-07 23:09:31 +0000 | [diff] [blame] | 168 | return thing |
| 169 | |
| 170 | def testTypedef(self, thing): |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 171 | if options.verbose > 1: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 172 | print 'testTypedef(%s)' % thing |
David Reiss | 7442127 | 2008-11-07 23:09:31 +0000 | [diff] [blame] | 173 | return thing |
| 174 | |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 175 | def testMapMap(self, thing): |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 176 | if options.verbose > 1: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 177 | print 'testMapMap(%s)' % thing |
Roger Meier | 1f554e1 | 2013-01-05 20:38:35 +0100 | [diff] [blame] | 178 | return {thing: {thing: thing}} |
| 179 | |
| 180 | def testInsanity(self, argument): |
| 181 | if options.verbose > 1: |
| 182 | print 'testInsanity(%s)' % argument |
| 183 | return {123489: {Numberz.ONE:argument}} |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 184 | |
| 185 | def testMulti(self, arg0, arg1, arg2, arg3, arg4, arg5): |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 186 | if options.verbose > 1: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 187 | print 'testMulti(%s)' % [arg0, arg1, arg2, arg3, arg4, arg5] |
Roger Meier | 1f554e1 | 2013-01-05 20:38:35 +0100 | [diff] [blame] | 188 | return Xtruct(string_thing='Hello2', |
| 189 | byte_thing=arg0, i32_thing=arg1, i64_thing=arg2) |
| 190 | |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 191 | |
Roger Meier | 7615072 | 2014-05-31 22:22:07 +0200 | [diff] [blame] | 192 | # set up the protocol factory form the --protocol option |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 193 | pfactory_cls = PROT_FACTORIES.get(options.proto, None) |
| 194 | if pfactory_cls is None: |
Roger Meier | 7615072 | 2014-05-31 22:22:07 +0200 | [diff] [blame] | 195 | raise AssertionError('Unknown --protocol option: %s' % options.proto) |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 196 | pfactory = pfactory_cls() |
| 197 | |
| 198 | # get the server type (TSimpleServer, TNonblockingServer, etc...) |
| 199 | if len(args) > 1: |
| 200 | raise AssertionError('Only one server type may be specified, not multiple types.') |
| 201 | server_type = args[0] |
| 202 | |
| 203 | # Set up the handler and processor objects |
jfarrell | dbf2bb5 | 2014-07-09 23:37:12 -0400 | [diff] [blame] | 204 | handler = TestHandler() |
| 205 | processor = ThriftTest.Processor(handler) |
David Reiss | bcaa2ad | 2008-06-10 22:55:26 +0000 | [diff] [blame] | 206 | |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 207 | # Handle THttpServer as a special case |
| 208 | if server_type == 'THttpServer': |
| 209 | server =THttpServer.THttpServer(processor, ('', options.port), pfactory) |
| 210 | server.serve() |
| 211 | sys.exit(0) |
| 212 | |
| 213 | # set up server transport and transport factory |
Roger Meier | 7615072 | 2014-05-31 22:22:07 +0200 | [diff] [blame] | 214 | |
Roger Meier | 7615072 | 2014-05-31 22:22:07 +0200 | [diff] [blame] | 215 | rel_path = "../keys/server.pem" |
| 216 | abs_key_path = os.path.join(script_dir, rel_path) |
| 217 | |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 218 | host = None |
| 219 | if options.ssl: |
| 220 | from thrift.transport import TSSLSocket |
Roger Meier | 7615072 | 2014-05-31 22:22:07 +0200 | [diff] [blame] | 221 | transport = TSSLSocket.TSSLServerSocket(host, options.port, certfile=abs_key_path) |
David Reiss | 7442127 | 2008-11-07 23:09:31 +0000 | [diff] [blame] | 222 | else: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 223 | transport = TSocket.TServerSocket(host, options.port) |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 224 | tfactory = TTransport.TBufferedTransportFactory() |
Roger Meier | 7615072 | 2014-05-31 22:22:07 +0200 | [diff] [blame] | 225 | if options.trans == 'buffered': |
| 226 | tfactory = TTransport.TBufferedTransportFactory() |
| 227 | elif options.trans == 'framed': |
| 228 | tfactory = TTransport.TFramedTransportFactory() |
| 229 | elif options.trans == '': |
| 230 | raise AssertionError('Unknown --transport option: %s' % options.trans) |
| 231 | else: |
| 232 | tfactory = TTransport.TBufferedTransportFactory() |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 233 | # if --zlib, then wrap server transport, and use a different transport factory |
| 234 | if options.zlib: |
| 235 | transport = TZlibTransport.TZlibTransport(transport) # wrap with zlib |
| 236 | tfactory = TZlibTransport.TZlibTransportFactory() |
| 237 | |
| 238 | # do server-specific setup here: |
| 239 | if server_type == "TNonblockingServer": |
| 240 | server = TNonblockingServer.TNonblockingServer(processor, transport, inputProtocolFactory=pfactory) |
| 241 | elif server_type == "TProcessPoolServer": |
| 242 | import signal |
| 243 | from thrift.server import TProcessPoolServer |
| 244 | server = TProcessPoolServer.TProcessPoolServer(processor, transport, tfactory, pfactory) |
| 245 | server.setNumWorkers(5) |
| 246 | def set_alarm(): |
| 247 | def clean_shutdown(signum, frame): |
| 248 | for worker in server.workers: |
| 249 | if options.verbose > 0: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 250 | print 'Terminating worker: %s' % worker |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 251 | worker.terminate() |
| 252 | if options.verbose > 0: |
Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 253 | print 'Requesting server to stop()' |
Roger Meier | f4eec7a | 2011-09-11 18:16:21 +0000 | [diff] [blame] | 254 | try: |
| 255 | server.stop() |
| 256 | except: |
| 257 | pass |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 258 | signal.signal(signal.SIGALRM, clean_shutdown) |
Jens Geyer | f7d327a | 2015-07-25 15:44:20 +0200 | [diff] [blame] | 259 | signal.alarm(4) |
Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 260 | set_alarm() |
| 261 | else: |
| 262 | # look up server class dynamically to instantiate server |
| 263 | ServerClass = getattr(TServer, server_type) |
| 264 | server = ServerClass(processor, transport, tfactory, pfactory) |
| 265 | # enter server main loop |
Mark Slee | 794993d | 2006-09-20 01:56:10 +0000 | [diff] [blame] | 266 | server.serve() |