Ir para conteúdo
  • Anúncios

    • Majesty

      Regras Notícias e Discussões   04/26/17

      Regras da seção Notícias e Discussões Tópicos: Essa seção é destinada para tópicos relacionados a discussões sobre Tibia e OTServ; Tópicos com anúncios de servidores são proibidos, por isso devem ser postados na seção Divulgação de Servidores. Tópicos com pedido de ajuda serão fechados, pois existe a seção Suporte - Dúvidas, Bugs, Erros. É permitido postar teasers de OTServ desde que não tenham nenhum link de divulgação. Posts: Posts devem ser relacionados ao assunto do tópico. Os que forem irregulares terão seus autores punidos. Outros tipos de posts proibidos e passíveis de punição são os com intuito de avisar ilegalidade do tópico ou que está sendo denunciado. Para isso, existe a opção Denunciar post.
Entre para seguir isso  
stian

PyOT updates, and looking for people.

Recommended Posts

stian    7
stian

 

 

Async programming is not so easy..a new architecture is needed.

Well, we are there now, and been there every since our really early releases. How to make a function call from reactor, wrap it with @gen.coroutine. Async SQL, if you don't care about the result, do this:

runOperation("INSERT INTO table VALUES(%d, %s, %s) ", id, string, another_string)

and the query will happen "in the background". Correctly formated with string escapes etc to prevent injections, automatically.

 

if you do care about the result, you can either do this:

runQuery("SELECT * FROM table", callback=callback)

where callback is a function which gets the result as a parameter.

 

or in a gen.coroutine function:

result = yield runQuery("SELECT * FROM table")

This is actually a Python PEP, for the DB API, so "all" libraries use this. http://legacy.python.org/dev/peps/

 

You can wrap such things around ORM stuff, like SQLAlchemy, but I personally like SQL queries 

Compartilhar este post


Link para o post
Yamaken    41
Yamaken

Oh sorry stian, i have said something wrong, i was saying pyot need a new architecture..

I was just saying, if i remember correctly there is a lot of queries in a lot of modules in pyot, i think if we need to change anything in the model we will have to change every query in every place...it would be better to have a class to abstract geting data from the model and puting data in the model...

Compartilhar este post


Link para o post
Elwyn    106
Elwyn

I'm trying to run it with python3.4, anyone else having trouble? Is the server supposed to create the database tables and so on? Can't seem to find a schema file with everything, just some files on "data/sql/" that I don't know if they are supposed to be the database schema since some of them overlap queries.

 

Edit:

I feel like there's too much on the main directory, is it necessary to have so much folders there? For clarity sake you can separate into "data" and "core", so you don't need to show too much to users who just want to write some scripts on "data".

Editado por Elwyn

Compartilhar este post


Link para o post
Lordfire    110
Lordfire

Asynchronous SQL is amazing. I bet you can make it as fast as if it was running on Node, without that shitty syntax that JS has.

 

I agree with Elwyn that the core of the server and the data can be separated for the sake of clarity.

Compartilhar este post


Link para o post
stian    7
stian

 

 

I bet you can make it as fast as if it was running on Node, without that shitty syntax that JS has.

The current speed is <how fast it takes to run it in synchronized mode> + <next reactor tick that synchronizes (this is min 4, tho the cost is very very small <1us>[ + <optionally next reactor tick that passes the result>]

 

 

 

I feel like there's too much on the main directory, is it necessary to have so much folders there? For clarity sake you can separate into "data" and "core", so you don't need to show too much to users who just want to write some scripts on "data".

Ye, I'll do some cleanups. And perhaps introduce an automatic installation system. That guides the user.

 

EDIT: Rev 2266. Install simpler than ever, just download, setup your config.py and run. No need to think about sql.

Editado por stian

Compartilhar este post


Link para o post
Nully    1
Nully

Much lower memory footprint than TFS, you can host a real map in like 250MB ram with some settings tweaks. It uses much less CPU as well. Sadly I don't have the pypy data for this, but it'll come.

 

A few strongpoints:

- The ability to use multiple game protocols, everything from 8.6 to 9.xx (currently), can be logged in to same server.

- Much simpler script system (TFS is seriously confussing, and hard to work with, xml files is such a waste).

- Async SQL, that is, TFS run an sql query and it takes 20ms, it "lags" for 20ms, in this, there is no lag. Just pure processing time.

- The ability to use multiple languages (say you want a native portuguese server, with the ability to also use english).

- Ability to run multiple words in one server (instances), get rid of mapping multiple rooms onto your map, do it once and load it in as many times you need.

 

It does have bugs, it does have places where it can be much better. It lake long time production testing.

 

EDIT: There is also the need to support 10.x clients, if anyone are up for it :)

Seems awesome. Can you talk about the pros and cons of using Python in a MMORPG ? Why do you choose Python for rewritten Opentibia ?

Compartilhar este post


Link para o post
stian    7
stian

Seems awesome. Can you talk about the pros and cons of using Python in a MMORPG ? Why do you choose Python for rewritten Opentibia ?

I choose python because it's easy, and with JIT compilers such as pypy, you break the speed of most C/C++ approches. Choose a good algorithm, is much better than how you implement it. Tibia doesn't really require to be optimized to the bone, out of a test with small test running around 10min with "aime" (not very scientific), only about 4 cpu seconds was spent doing anything. This test involved a mix of everything from loading the server, to loading the maps, monsters, teleporting, stairjumping, cryptography, complex pathfindings....

 

Under python2, pypy did the job about 4 times better than cpython, so under pypy3 2.4 (upcoming release) we might not expect faster load time, but when warmed up, maybe a 3-5x speedup.

 

To put that in perspective, TFS use about 1.6s cpu seconds on a highly optimized build. About 2.5s stock just to load an evo. So there is nothing to say on the performance.

 

Python is used in many MMORPGs, EVE Online is a famous example.

Editado por stian

Compartilhar este post


Link para o post
Nully    1
Nully

I choose python because it's easy, and with JIT compilers such as pypy, you break the speed of most C/C++ approches. Choose a good algorithm, is much better than how you implement it. Tibia doesn't really require to be optimized to the bone, out of a test with small test running around 10min with "aime" (not very scientific), only about 4 cpu seconds was spent doing anything. This test involved a mix of everything from loading the server, to loading the maps, monsters, teleporting, stairjumping, cryptography, complex pathfindings....

 

Under python2, pypy did the job about 4 times better than cpython, so under pypy3 2.4 (upcoming release) we might not expect faster load time, but when warmed up, maybe a 3-5x speedup.

 

To put that in perspective, TFS use about 1.6s cpu seconds on a highly optimized build. About 2.5s stock just to load an evo. So there is nothing to say on the performance.

 

Python is used in many MMORPGs, EVE Online is a famous example.

I'll search more about Python later :D
 
btw,
What things is missing in PyOT right now and what is planned to be added too ?
Editado por Nully

Compartilhar este post


Link para o post
Elwyn    106
Elwyn
Ye, I'll do some cleanups. And perhaps introduce an automatic installation system. That guides the user.

 

EDIT: Rev 2266. Install simpler than ever, just download, setup your config.py and run. No need to think about sql

 

gameserver.py didn't setup the database, but thanks to it I found what's the .sql that I was supposed to use as scheme. I'm dumb for not reading the README. lol

 

Edit:

 

Using python3.4.

Loginserver seems to starts ok and I can connect to character list.

Once I try to connect to gameserver I get a timeout, if I look at the terminal I can see that the connection is made and lost at the same time:

 

Connection made from ('127.0.0.1', 41304)
Connection lost from ('127.0.0.1', 41304)

 

I'm still studying Tornado to be able to help by myself instead of just reporting errors, but for now I can only report this ):

Editado por Elwyn

Compartilhar este post


Link para o post
stian    7
stian

Are you using the latest rev? Do you get an exception if you close the server (ctrl + c)?

Compartilhar este post


Link para o post
Elwyn    106
Elwyn

Are you using the latest rev? Do you get an exception if you close the server (ctrl + c)?

 

Latest rev, did get an exception closing the server with Ctrl + C

 

Exception:

 

 

Traceback (most recent call last):
  File "gameserver.py", line 65, in <module>
    IOLoop.instance().start()
  File "/usr/local/lib/python3.4/dist-packages/tornado/platform/asyncio.py", line 107, in start
    self.asyncio_loop.run_forever()
  File "/usr/lib/python3.4/asyncio/base_events.py", line 184, in run_forever
    self._run_once()
  File "/usr/lib/python3.4/asyncio/base_events.py", line 799, in _run_once
    event_list = self._selector.select(timeout)
  File "/usr/lib/python3.4/selectors.py", line 424, in select
    fd_event_list = self._epoll.poll(timeout, max_ev)
KeyboardInterrup

Compartilhar este post


Link para o post
stian    7
stian

You are not on the latest, because

 File "gameserver.py", line 65, in <module>
    IOLoop.instance().start()

is on line 74 in the latest :)

 

(And you don't get KeyboardInterrup)

Compartilhar este post


Link para o post
Elwyn    106
Elwyn

You are not on the latest, because

 File "gameserver.py", line 65, in <module>
    IOLoop.instance().start()

is on line 74 in the latest :)

 

(And you don't get KeyboardInterrup)

 

I'll clone it again just to be sure, but hg pull was not giving me any update. I'll edit here when it finish cloning.

 

Edit:

Cloned again, now I don't get an exception for Ctrl+C, tho I still can't connect.

Connection lost from ('127.0.0.1', 47690)

Connection made from ('127.0.0.1', 47690)

 

Some additional info: This happens with every client I tested using Tibia Client and OTClient, on Linux. Thought it may had something to do with forcing kill and not ending properly Tornado so I restarted the pc to be sure but I'm still with those errors.

Editado por Elwyn

Compartilhar este post


Link para o post
stian    7
stian

What client versions? I have to admit I haven't tested any other than 8.6 since the porting to python3.

 

Did you install tornado using pip, or using the package system?

Compartilhar este post


Link para o post
Elwyn    106
Elwyn

Using pip3

pip 1.5.4 from /usr/lib/python3/dist-packages (python 3.4)

Using Python 3.4.0

Tested with 8.6 and 9.81 on normal client, otclient

 

Do you want me to make a topic on Vapus with more details?

I'm using Linux Mint 17, Cinnamon

Editado por Elwyn

Compartilhar este post


Link para o post
stian    7
stian

Using pip3

pip 1.5.4 from /usr/lib/python3/dist-packages (python 3.4)

Using Python 3.4.0

Tested with 8.6 and 9.81 on normal client, otclient

 

Do you want me to make a topic on Vapus with more details?

I'm using Linux Mint 17, Cinnamon

Ye, perhaps make a seperate thread (or fill an issue on bitbucket), as to not fill this topic with ehm, off-topic support. :)

Compartilhar este post


Link para o post
Elwyn    106
Elwyn

Ok, I'll make an issue on bitbucket.

 

Link: https://bitbucket.org/vapus/pyot/issue/1/connection-lost-on-trying-to-connect-to

 

Edit:

There's too much errors, don't know if it's because of compatibility. Minor errors like str to byte or byte to str I fixed on my own, but those errors now I'm still trying to figure out how to fix. Isn't it better to start again from scratch using what we have until now only as base to the new code in Python 3?

 

Errors:

 

http://pastebin.com/yi14tGrE

Editado por Elwyn

Compartilhar este post


Link para o post
Lordfire    110
Lordfire

Stian, what to you think on having an embedded HTTP API with the server? Using Flask this should be really easy.

 

With an embedded API, creating a website would be as easy as connecting Ember, Backbone or Angular with the correct paths. To the date, creating a website is really time consuming, since most PHP frameworks are heavy and it requires configuring a separate server for HTTP, while using an API would have just static files that could be served buy GitHub Pages or something like that.

Compartilhar este post


Link para o post
stian    7
stian

The server does have a HTTP sytem (*Not ported to python3!), serving the web_static folder of data, or the web folder for python dynamic pages. Ofc this can be refactored to anything, altho Tornado IS a high performance HTTP server by itself, used by facebook friendfeed etc.

Compartilhar este post


Link para o post
Lordfire    110
Lordfire

That's great :D I'll take a look as soon as I can.

Compartilhar este post


Link para o post
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×