@@ -1341,8 +1341,9 @@ if __name__ == '__main__':
13411341
13421342Note that:
13431343
1344- 1 . Calling ` main ` is simply equivalent to starting ` proxy.py ` from command line.
1345- 2 . ` main ` doesn't accept any ` *args ` . It will automatically parse any available ` sys.argv ` .
1344+ 1 . ` main ` is equivalent to starting ` proxy.py ` from command line.
1345+ 2 . ` main ` does not accept any ` args ` (only ` kwargs ` ).
1346+ 3 . ` main ` will automatically consume any available ` sys.argv ` as ` args ` .
134613473 . ` main ` will block until ` proxy.py ` shuts down.
13471348
13481349## Non-blocking Mode
@@ -1355,19 +1356,20 @@ import proxy
13551356
13561357if __name__ == ' __main__' :
13571358 with proxy.Proxy() as p:
1358- # ... your logic here ...
1359+ # Uncomment the line below and
1360+ # implement your app your logic here
1361+ proxy.sleep_loop()
13591362```
13601363
13611364Note that:
13621365
1363- 1 . ` Proxy ` is similar to ` main ` , except ` Proxy ` does not block.
1364- 2 . Internally ` Proxy ` is a context manager.
1365- 3 . It will start ` proxy.py ` when called and will shut it down
1366- once the scope ends.
1367- 4 . However, unlike ` main ` , startup flags with ` Proxy `
1368- can also be customized by either passing flags as list of
1369- input arguments e.g. ` Proxy(['--port', '8899']) ` or
1366+ 1 . ` Proxy ` is similar to ` main ` , except ` Proxy ` will not block.
1367+ 2 . Internally, ` Proxy ` is a context manager which will start
1368+ ` proxy.py ` when called and will shut it down once the scope ends.
1369+ 3 . Unlike ` main ` , startup flags with ` Proxy ` can also be customized
1370+ by using ` args ` and ` kwargs ` . e.g. ` Proxy(['--port', '8899']) ` or
13701371 by using passing flags as kwargs e.g. ` Proxy(port=8899) ` .
1372+ 4 . Unlike ` main ` , ` Proxy ` will not inspect ` sys.argv ` .
13711373
13721374## Ephemeral Port
13731375
@@ -1381,6 +1383,7 @@ import proxy
13811383if __name__ == ' __main__' :
13821384 with proxy.Proxy() as p:
13831385 print (p.flags.port)
1386+ proxy.sleep_loop()
13841387```
13851388
13861389` flags.port ` will give you access to the random port allocated by the kernel.
0 commit comments